Apache Geode Native C++ Reference 1.15.0
apache::geode::client::CacheableEnum Class Reference

Since C++ enums cannot be directly passed as a parameter to PdxWriter's writeObject and PdxReader's readObject api, wrap C++ enums with an immutable wrapper CacheableEnum class type by specifying enum class name, enum value name and its ordinal. More...

#include <CacheableEnum.hpp>

Inherits internal::DataSerializablePrimitive, and apache::geode::client::CacheableKey.

Public Member Functions

const std::string & getEnumClassName () const
 
const std::string & getEnumName () const
 
int32_t getEnumOrdinal () const
 
virtual int32_t hashcode () const override
 
virtual size_t objectSize () const override
 return the size in bytes of the instance being serialized. More...
 
virtual bool operator== (const CacheableKey &other) const override
 
virtual std::string toString () const override
 Display this object as c string. More...
 

Static Public Member Functions

template<class _T >
static std::shared_ptr< CacheableKeycreate (_T value)
 Factory method that creates the key type that matches the type of value. More...
 
static std::shared_ptr< CacheableEnumcreate (std::string enumClassName, std::string enumName, int32_t ordinal)
 Factory method for creating an instance of CacheableEnum. More...
 
static std::shared_ptr< SerializablecreateDeserializable ()
 creation function for enum. More...
 

Detailed Description

Since C++ enums cannot be directly passed as a parameter to PdxWriter's writeObject and PdxReader's readObject api, wrap C++ enums with an immutable wrapper CacheableEnum class type by specifying enum class name, enum value name and its ordinal.

C++ enum allows explicit setting of ordinal number, but it is up to the user to map java enumName with that of C++ enumName. Currently this wrapper only works as part of PdxSerializable member object and cannot be directly used in Region operations.

See also
PdxWriter::writeObject
PdxReader::readObject

Member Function Documentation

◆ create() [1/2]

template<class _T >
static std::shared_ptr< CacheableKey > apache::geode::client::CacheableKey::create ( _T  value)
staticinherited

Factory method that creates the key type that matches the type of value.

For user defined derivations of CacheableKey, the method apache::geode::client::CacheableKey::create may be overloaded.

◆ create() [2/2]

static std::shared_ptr< CacheableEnum > apache::geode::client::CacheableEnum::create ( std::string  enumClassName,
std::string  enumName,
int32_t  ordinal 
)
inlinestatic

Factory method for creating an instance of CacheableEnum.

Parameters
enumClassNamethe name of the enum class that maps to the java enum type.
enumNamethe name of the enum constant that maps to the java enum type.
ordinalthe ordinal value of the enum constant that maps to the java enum type.
Returns
a CacheableEnum representing C++ enum.

◆ createDeserializable()

static std::shared_ptr< Serializable > apache::geode::client::CacheableEnum::createDeserializable ( )
inlinestatic

creation function for enum.

◆ getEnumClassName()

const std::string & apache::geode::client::CacheableEnum::getEnumClassName ( ) const
inline
Returns
enum class name.

◆ getEnumName()

const std::string & apache::geode::client::CacheableEnum::getEnumName ( ) const
inline
Returns
enum name.

◆ getEnumOrdinal()

int32_t apache::geode::client::CacheableEnum::getEnumOrdinal ( ) const
inline
Returns
enum ordinal.

◆ hashcode()

virtual int32_t apache::geode::client::CacheableEnum::hashcode ( ) const
inlineoverridevirtual
Returns
the hashcode for this key.

Implements apache::geode::client::CacheableKey.

◆ objectSize()

virtual size_t apache::geode::client::CacheableEnum::objectSize ( ) const
inlineoverridevirtual

return the size in bytes of the instance being serialized.

This is used to determine whether the cache is using up more physical memory than it has been configured to use. The method can return zero if the user does not require the ability to control cache memory utilization. Note that you must implement this only if you use the HeapLRU feature.

Reimplemented from apache::geode::client::Serializable.

◆ operator==()

virtual bool apache::geode::client::CacheableEnum::operator== ( const CacheableKey other) const
overridevirtual
Returns
true if this key matches other.

Implements apache::geode::client::CacheableKey.

◆ toString()

virtual std::string apache::geode::client::CacheableEnum::toString ( ) const
inlineoverridevirtual

Display this object as c string.

Reimplemented from apache::geode::client::Serializable.


Apache Geode C++ Cache API Documentation