build-artifacts/win/product/include/gfcpp/CacheableEnum.hpp

00001 /*=========================================================================
00002  * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
00003  * This product is protected by U.S. and international copyright
00004  * and intellectual property laws. Pivotal products are covered by
00005  * one or more patents listed at http://www.pivotal.io/patents.
00006  *=========================================================================
00007  */
00008 #ifndef CACHEABLE_ENUM_HPP
00009 #define CACHEABLE_ENUM_HPP
00010 
00011 #include "CacheableKey.hpp"
00012 #include "CacheableString.hpp"
00013 
00014 namespace gemfire {
00015 
00026   class CPPCACHE_EXPORT CacheableEnum : public CacheableKey {
00027   private:
00028     CacheableStringPtr m_enumClassName;
00029     CacheableStringPtr m_enumName;
00030     int32_t            m_ordinal;
00031     mutable int32_t    m_hashcode;
00032 
00033   public:
00034 
00036     ~CacheableEnum();
00037 
00041     static Serializable* createDeserializable(){
00042       return new CacheableEnum();
00043     }
00047     virtual void toData(DataOutput& output) const;
00048 
00052     virtual Serializable* fromData(DataInput& input);
00053 
00055     virtual uint32_t objectSize() const {
00056       uint32_t size = sizeof( CacheableEnum );
00057       size += (uint32_t)sizeof(int32_t);
00058       size += m_enumClassName->objectSize();
00059       size += m_enumName->objectSize();
00060       return size;
00061     }
00062 
00068     virtual int32_t classId() const {
00069       return 0;
00070     }
00071 
00077     virtual int8_t typeId() const {      
00078       //return 0;
00079       return (int8_t) GemfireTypeIds::CacheableEnum;
00080     }
00081 
00085     virtual CacheableStringPtr toString() const {
00086       return CacheableString::create("CacheableEnum");
00087     }
00088 
00096     static CacheableEnumPtr create(const char* enumClassName, const char* enumName, int32_t ordinal) {         
00097       CacheableEnumPtr str( new CacheableEnum(enumClassName, enumName, ordinal));
00098       return str;
00099     }
00100 
00102     const char* getEnumClassName() const {         
00103       return m_enumClassName->asChar();      
00104     }
00105 
00107     const char* getEnumName() const {         
00108       return m_enumName->asChar();      
00109     }
00110 
00112     int32_t getEnumOrdinal() const {         
00113       return m_ordinal;      
00114     } 
00115 
00117     virtual uint32_t hashcode( ) const;
00118 
00120     virtual bool operator==(const CacheableKey& other) const;
00121   protected:
00122     CacheableEnum();
00123     CacheableEnum(const char* enumClassName, const char* enumName, int32_t ordinal);
00124   private:
00125     // never implemented.
00126     void operator =(const CacheableEnum& other);
00127     CacheableEnum(const CacheableEnum& other);
00128 
00129   };  
00130 }
00131 
00132 #endif //CACHEABLE_ENUM_HPP

GemFire C++ Cache API Documentation