VMware GemFire Native C++ Reference  9.1
CacheableEnum.hpp
1 #pragma once
2 
3 #ifndef GEODE_CACHEABLEENUM_H_
4 #define GEODE_CACHEABLEENUM_H_
5 
6 /*
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements. See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include "CacheableKey.hpp"
24 #include "CacheableString.hpp"
25 
26 namespace apache {
27 namespace geode {
28 namespace client {
29 
45  private:
46  CacheableStringPtr m_enumClassName;
47  CacheableStringPtr m_enumName;
48  int32_t m_ordinal;
49  mutable int32_t m_hashcode;
50 
51  public:
53  ~CacheableEnum();
54 
58  static Serializable* createDeserializable() { return new CacheableEnum(); }
62  virtual void toData(DataOutput& output) const;
63 
67  virtual Serializable* fromData(DataInput& input);
68 
70  virtual uint32_t objectSize() const {
71  uint32_t size = sizeof(CacheableEnum);
72  size += static_cast<uint32_t>(sizeof(int32_t));
73  size += m_enumClassName->objectSize();
74  size += m_enumName->objectSize();
75  return size;
76  }
77 
83  virtual int32_t classId() const { return 0; }
84 
90  virtual int8_t typeId() const {
91  // return 0;
92  return static_cast<int8_t>(GeodeTypeIds::CacheableEnum);
93  }
94 
98  virtual CacheableStringPtr toString() const {
99  return CacheableString::create("CacheableEnum");
100  }
101 
111  static CacheableEnumPtr create(const char* enumClassName,
112  const char* enumName, int32_t ordinal) {
113  CacheableEnumPtr str(new CacheableEnum(enumClassName, enumName, ordinal));
114  return str;
115  }
116 
118  const char* getEnumClassName() const { return m_enumClassName->asChar(); }
119 
121  const char* getEnumName() const { return m_enumName->asChar(); }
122 
124  int32_t getEnumOrdinal() const { return m_ordinal; }
125 
127  virtual int32_t hashcode() const;
128 
130  virtual bool operator==(const CacheableKey& other) const;
131 
132  protected:
133  CacheableEnum();
134  CacheableEnum(const char* enumClassName, const char* enumName,
135  int32_t ordinal);
136 
137  private:
138  // never implemented.
139  void operator=(const CacheableEnum& other);
140  CacheableEnum(const CacheableEnum& other);
141 };
142 } // namespace client
143 } // namespace geode
144 } // namespace apache
145 
146 #endif // GEODE_CACHEABLEENUM_H_
static Serializable * createDeserializable()
creation function for enum.
Definition: CacheableEnum.hpp:58
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
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:113
virtual uint32_t objectSize() const
return the size in bytes of the instance being serialized.
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableEnum.hpp:83
int32_t getEnumOrdinal() const
Definition: CacheableEnum.hpp:124
const char * asChar() const
Return the string that backs this CacheableString as a char *.
Definition: CacheableString.hpp:194
virtual CacheableStringPtr toString() const
Display this object as c string.
Definition: CacheableEnum.hpp:98
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:74
Since C++ enums cannot be directly passed as a parameter to PdxWriter&#39;s writeObject and PdxReader&#39;s r...
Definition: CacheableEnum.hpp:44
const char * getEnumClassName() const
Definition: CacheableEnum.hpp:118
const char * getEnumName() const
Definition: CacheableEnum.hpp:121
virtual int8_t typeId() const
return the typeId byte of the instance being serialized.
Definition: CacheableEnum.hpp:90
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:53
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:56
Represents a cacheable key.
Definition: CacheableKey.hpp:36
static CacheableEnumPtr create(const char *enumClassName, const char *enumName, int32_t ordinal)
Factory method for creating an instance of CacheableEnum.
Definition: CacheableEnum.hpp:111
virtual uint32_t objectSize() const
Definition: CacheableEnum.hpp:70
This namespace contains all the Geode C++ API classes, enumerations and globals.

Pivotal GemFire C++ Cache API Documentation