VMware GemFire Native Client Cache Reference  9.0.6
CacheableEnum.hpp
1 /*=========================================================================
2  * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
3  * This product is protected by U.S. and international copyright
4  * and intellectual property laws. Pivotal products are covered by
5  * one or more patents listed at http://www.pivotal.io/patents.
6  *=========================================================================
7  */
8 #ifndef CACHEABLE_ENUM_HPP
9 #define CACHEABLE_ENUM_HPP
10 
11 #include "CacheableKey.hpp"
12 #include "CacheableString.hpp"
13 
14 namespace gemfire {
15 
27  private:
28  CacheableStringPtr m_enumClassName;
29  CacheableStringPtr m_enumName;
30  int32_t m_ordinal;
31  mutable int32_t m_hashcode;
32 
33  public:
34 
36  ~CacheableEnum();
37 
42  return new CacheableEnum();
43  }
47  virtual void toData(DataOutput& output) const;
48 
52  virtual Serializable* fromData(DataInput& input);
53 
55  virtual uint32_t objectSize() const {
56  uint32_t size = sizeof( CacheableEnum );
57  size += (uint32_t)sizeof(int32_t);
58  size += m_enumClassName->objectSize();
59  size += m_enumName->objectSize();
60  return size;
61  }
62 
68  virtual int32_t classId() const {
69  return 0;
70  }
71 
77  virtual int8_t typeId() const {
78  //return 0;
79  return (int8_t) GemfireTypeIds::CacheableEnum;
80  }
81 
85  virtual CacheableStringPtr toString() const {
86  return CacheableString::create("CacheableEnum");
87  }
88 
96  static CacheableEnumPtr create(const char* enumClassName, const char* enumName, int32_t ordinal) {
97  CacheableEnumPtr str( new CacheableEnum(enumClassName, enumName, ordinal));
98  return str;
99  }
100 
102  const char* getEnumClassName() const {
103  return m_enumClassName->asChar();
104  }
105 
107  const char* getEnumName() const {
108  return m_enumName->asChar();
109  }
110 
112  int32_t getEnumOrdinal() const {
113  return m_ordinal;
114  }
115 
117  virtual uint32_t hashcode( ) const;
118 
120  virtual bool operator==(const CacheableKey& other) const;
121  protected:
122  CacheableEnum();
123  CacheableEnum(const char* enumClassName, const char* enumName, int32_t ordinal);
124  private:
125  // never implemented.
126  void operator =(const CacheableEnum& other);
127  CacheableEnum(const CacheableEnum& other);
128 
129  };
130 }
131 
132 #endif //CACHEABLE_ENUM_HPP
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:62
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableEnum.hpp:68
static Serializable * createDeserializable()
creation function for enum.
Definition: CacheableEnum.hpp:41
static CacheableEnumPtr create(const char *enumClassName, const char *enumName, int32_t ordinal)
Factory method for creating an instance of CacheableEnum.
Definition: CacheableEnum.hpp:96
Represents a cacheable key.
Definition: CacheableKey.hpp:23
const char * getEnumClassName() const
Definition: CacheableEnum.hpp:102
static CacheableStringPtr create(const char *value, int32_t len=0)
Factory method for creating an instance of CacheableString from a null terminated C string optionally...
Definition: CacheableString.hpp:102
virtual CacheableStringPtr toString() const
Display this object as c string.
Definition: CacheableEnum.hpp:85
const char * asChar() const
Return the string that backs this CacheableString as a char *.
Definition: CacheableString.hpp:189
virtual uint32_t objectSize() const
Definition: CacheableEnum.hpp:55
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
virtual uint32_t objectSize() const
return the size in bytes of the instance being serialized.
Since C++ enums cannot be directly passed as a parameter to PdxWriter's writeObject and PdxReader's r...
Definition: CacheableEnum.hpp:26
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:39
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:44
int32_t getEnumOrdinal() const
Definition: CacheableEnum.hpp:112
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
const char * getEnumName() const
Definition: CacheableEnum.hpp:107
virtual int8_t typeId() const
return the typeId byte of the instance being serialized.
Definition: CacheableEnum.hpp:77

GemFire C++ Cache API Documentation