3 #ifndef GEODE_CACHEABLEBUILTINS_H_ 4 #define GEODE_CACHEABLEBUILTINS_H_ 32 #include "Serializer.hpp" 33 #include "CacheableKeys.hpp" 41 extern int gf_sprintf(
char* buffer,
const char* fmt, ...);
44 extern int gf_snprintf(
char* buffer, int32_t maxLength,
const char* fmt, ...);
47 template <
typename TObj, int8_t TYPEID,
const char* TYPENAME,
48 const char* SPRINTFSYM, int32_t STRSIZE>
54 : m_value(apache::geode::client::serializer::zeroObject<TObj>()) {}
60 inline TObj
value()
const {
return m_value; }
66 apache::geode::client::serializer::writeObject(output, m_value);
71 apache::geode::client::serializer::readObject(input, m_value);
81 virtual int32_t
classId()
const {
return 0; }
89 virtual int8_t
typeId()
const {
return TYPEID; }
93 char buffer[STRSIZE + 1];
102 return apache::geode::client::serializer::hashcode(m_value);
107 if (other.
typeId() != TYPEID) {
112 return apache::geode::client::serializer::equals(m_value,
118 return apache::geode::client::serializer::equals(m_value, other);
125 virtual int32_t
logString(
char* buffer, int32_t maxLength)
const {
127 gf_sprintf(fmt,
"%s( %s )", TYPENAME, SPRINTFSYM);
128 return gf_snprintf(buffer, maxLength, fmt, m_value);
143 template <
typename TObj,
int8_t TYPEID>
147 template <
typename TObj>
148 inline void copyArray(TObj* dest,
const TObj* src, int32_t length) {
149 std::memcpy(dest, src, length *
sizeof(TObj));
156 template <
typename TObj>
159 for (int32_t index = 0; index < length; index++) {
160 dest[index] = src[index];
168 template <
typename TObj,
int8_t TYPEID>
171 for (int32_t index = 0; index < length; index++) {
172 dest[index] = src[index];
177 template <
typename TObj,
int8_t TYPEID>
187 GF_NEW(m_value, TObj[length]);
192 : m_value(value), m_length(length) {}
195 : m_value(NULL), m_length(length) {
197 GF_NEW(m_value, TObj[length]);
207 : m_value(other.m_value), m_length(other.m_length) {}
215 inline const TObj*
value()
const {
return m_value; }
218 inline int32_t
length()
const {
return m_length; }
222 if (static_cast<int32_t>(index) >= m_length) {
223 throw OutOfRangeException(
224 "CacheableArray::operator[]: Index out of range.");
226 return m_value[index];
233 apache::geode::client::serializer::writeObject(output, m_value, m_length);
239 apache::geode::client::serializer::readObject(input, m_value, m_length);
257 virtual int8_t
typeId()
const {
return TYPEID; }
268 return static_cast<uint32_t
>(
270 apache::geode::client::serializer::objectSize(m_value, m_length));
277 template <
typename TObj,
int8_t TYPEID>
299 template <
typename TOther,
int8_t OTHERID>
304 template <
typename TOther>
321 template <
typename TBase,
int8_t TYPEID>
333 apache::geode::client::serializer::writeObject(output, *
this);
338 apache::geode::client::serializer::readObject(input, *
this);
356 virtual int8_t
typeId()
const {
return TYPEID; }
367 return static_cast<uint32_t
>(
369 apache::geode::client::serializer::objectSize(*
this));
374 #define TEMPLATE_EXPORT template class 376 #ifdef BUILD_CPPCACHE 377 #define TEMPLATE_EXPORT template class CPPCACHE_EXPORT 379 #define TEMPLATE_EXPORT extern template class CPPCACHE_EXPORT 385 #pragma warning(disable : 4231) 388 #define _GF_CACHEABLE_KEY_TYPE_DEF_(p, k, sz) \ 389 extern const char tName_##k[]; \ 390 extern const char tStr_##k[]; \ 392 CacheableKeyType<p, GeodeTypeIds::k, tName_##k, tStr_##k, sz>; \ 393 typedef CacheableKeyType<p, GeodeTypeIds::k, tName_##k, tStr_##k, sz> _##k; \ 394 class CPPCACHE_EXPORT k; \ 395 typedef SharedPtr<k> k##Ptr; 398 #define _GF_CACHEABLE_KEY_TYPE_(p, k, sz) \ 399 class CPPCACHE_EXPORT k : public _##k { \ 401 inline k() : _##k() {} \ 402 inline k(const p value) : _##k(value) {} \ 406 static Serializable* createDeserializable() { return new k(); } \ 408 inline static k##Ptr create() { return k##Ptr(new k()); } \ 410 inline static k##Ptr create(const p value) { \ 411 return k##Ptr(new k(value)); \ 414 inline CacheableKeyPtr createKey(const p value) { return k::create(value); } \ 415 inline CacheablePtr createValue(const p value) { return k::create(value); } 417 #define _GF_CACHEABLE_ARRAY_TYPE_DEF_(p, c) \ 418 TEMPLATE_EXPORT CacheableArrayType<p, GeodeTypeIds::c>; \ 419 typedef CacheableArrayType<p, GeodeTypeIds::c> _##c; \ 420 class CPPCACHE_EXPORT c; \ 421 typedef SharedArrayPtr<p, GeodeTypeIds::c> c##Ptr; 424 #define _GF_CACHEABLE_ARRAY_TYPE_(p, c) \ 425 class CPPCACHE_EXPORT c : public _##c { \ 427 inline c() : _##c() {} \ 428 inline c(int32_t length) : _##c(length) {} \ 429 inline c(p* value, int32_t length) : _##c(value, length) {} \ 430 inline c(const p* value, int32_t length, bool copy) \ 431 : _##c(value, length, true) {} \ 436 c& operator=(const c& other); \ 440 static Serializable* createDeserializable() { return new c(); } \ 442 inline static c##Ptr create() { return c##Ptr(new c()); } \ 444 inline static c##Ptr create(int32_t length) { \ 445 return c##Ptr(new c(length)); \ 448 inline static c##Ptr create(const p* value, int32_t length) { \ 449 return (value != NULL ? c##Ptr(new c(value, length, true)) : NULLPTR); \ 473 inline static c##Ptr createNoCopy(p* value, int32_t length) { \ 474 return (value != NULL ? c##Ptr(new c(value, length)) : NULLPTR); \ 478 #define _GF_CACHEABLE_CONTAINER_TYPE_DEF_(p, c) \ 479 TEMPLATE_EXPORT CacheableContainerType<p, GeodeTypeIds::c>; \ 480 typedef CacheableContainerType<p, GeodeTypeIds::c> _##c; \ 481 class CPPCACHE_EXPORT c; \ 482 typedef SharedPtr<c> c##Ptr; 485 #define _GF_CACHEABLE_CONTAINER_TYPE_(p, c) \ 486 class CPPCACHE_EXPORT c : public _##c { \ 488 inline c() : _##c() {} \ 489 inline c(const int32_t n) : _##c(n) {} \ 493 typedef p::Iterator Iterator; \ 495 static Serializable* createDeserializable() { return new c(); } \ 497 inline static c##Ptr create() { return c##Ptr(new c()); } \ 499 inline static c##Ptr create(const int32_t n) { return c##Ptr(new c(n)); } \ 567 _GF_CACHEABLE_ARRAY_TYPE_DEF_(
wchar_t,
CharArray);
702 #endif // GEODE_CACHEABLEBUILTINS_H_ A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:686
int gf_snprintf(char *buffer, int32_t maxLength, const char *fmt,...)
snprintf implementation.
A mutable CacheableKey hash set wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:646
virtual int32_t hashcode() const
Return the hashcode for this key.
Definition: CacheableBuiltins.hpp:101
const TObj * value() const
Get the underlying array.
Definition: CacheableBuiltins.hpp:215
An immutable wrapper for booleans that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:509
SharedArrayPtr(const NullSharedBase *ptr)
Constructor, given a null SharedBase.
Definition: CacheableBuiltins.hpp:291
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:366
An immutable wrapper for 32-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:551
An immutable wrapper for doubles that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:530
SharedArrayPtr(const SharedArrayPtr< TOther, OTHERID > &other)
Constructor, given another kind of SharedArrayPtr.
Definition: CacheableBuiltins.hpp:300
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
An immutable wrapper for array of 64-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:616
virtual int8_t typeId() const
return the typeId byte of the instance being serialized.
TObj operator[](uint32_t index) const
Get the element at given index.
Definition: CacheableBuiltins.hpp:309
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:89
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:257
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
SharedArrayPtr(const TArray *ptr)
Constructor, given a pointer to array.
Definition: CacheableBuiltins.hpp:287
A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:675
virtual CacheableStringPtr toString() const
Return a string representation of the object.
Definition: CacheableBuiltins.hpp:92
A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:639
int32_t length() const
Get the length of the array.
Definition: CacheableBuiltins.hpp:218
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:348
An immutable wrapper for wide-characters that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:565
An immutable wrapper for array of booleans that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:516
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:249
Class encapsulating a NULL SharedBase smart pointer.
Definition: SharedBase.hpp:73
HashMap of TKEY to TVAL.
Definition: HashMapT.hpp:38
bool operator==(const TObj other) const
Return true if this key matches other key value.
Definition: CacheableBuiltins.hpp:117
An immutable wrapper for array of strings that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:623
Template class for array of primitive types.
Definition: CacheableBuiltins.hpp:178
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:74
An immutable wrapper for array of 16-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:602
virtual void toData(DataOutput &output) const
Serialize this object to given DataOutput.
Definition: CacheableBuiltins.hpp:65
#define GF_SAFE_DELETE_ARRAY(x)
Deletes array x only if it exists.
Definition: geode_base.hpp:311
An immutable wrapper for byte arrays that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:581
Template class for CacheableArrayType SharedPtr's that adds [] operator.
Definition: CacheableBuiltins.hpp:144
int gf_sprintf(char *buffer, const char *fmt,...)
sprintf implementation.
An immutable wrapper for 64-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:558
virtual Serializable * fromData(DataInput &input)
Deserialize this object from the given DataInput.
Definition: CacheableBuiltins.hpp:237
A mutable Cacheable array list wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:661
TObj operator[](uint32_t index) const
Get the element at given index.
Definition: CacheableBuiltins.hpp:221
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:139
Template CacheableKey class for primitive types.
Definition: CacheableBuiltins.hpp:49
virtual int32_t logString(char *buffer, int32_t maxLength) const
Copy the string form of the object into a char* buffer for logging purposes.
Definition: CacheableBuiltins.hpp:125
An immutable wrapper for array of floats that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:595
HashSet of TKEY.
Definition: HashSetT.hpp:36
TObj value() const
Gets the contained value.
Definition: CacheableBuiltins.hpp:60
void copyArray(TObj *dest, const TObj *src, int32_t length)
Function to copy an array from source to destination.
Definition: CacheableBuiltins.hpp:148
virtual Serializable * fromData(DataInput &input)
Deserialize this object from given DataInput.
Definition: CacheableBuiltins.hpp:70
An immutable wrapper for 16-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:544
Template class for container Cacheable types.
Definition: CacheableBuiltins.hpp:322
virtual void toData(DataOutput &output) const
Serialize this object to the given DataOutput.
Definition: CacheableBuiltins.hpp:232
A mutable Cacheable vector wrapper that can serve as a distributable object for caching.
Definition: CacheableBuiltins.hpp:632
An immutable wrapper for bytes that can serve as a distributable key object for caching.
Definition: CacheableBuiltins.hpp:523
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:53
Serializable * fromData(DataInput &input)
Deserialize self.
Definition: CacheableBuiltins.hpp:315
SharedArrayPtr(const SharedPtr< TOther > &other)
Constructor, given another SharedPtr.
Definition: CacheableBuiltins.hpp:305
virtual Serializable * fromData(DataInput &input)
Deserialize this object from the given DataInput.
Definition: CacheableBuiltins.hpp:337
A mutable CacheableKey hash set wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:697
A mutable Cacheable array list wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:653
Vector template type class.
Definition: VectorT.hpp:37
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
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:267
An immutable wrapper for array of 32-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:609
An immutable wrapper for array of doubles that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:588
#define GF_NEW(v, stmt)
Allocates x and throws OutOfMemoryException if it fails.
Definition: geode_base.hpp:293
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:356
virtual void toData(DataOutput &output) const
Serialize this object to the given DataOutput.
Definition: CacheableBuiltins.hpp:332
SharedArrayPtr()
Default constructor.
Definition: CacheableBuiltins.hpp:284
virtual bool operator==(const CacheableKey &other) const
Return true if this key matches other.
Definition: CacheableBuiltins.hpp:106
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:81
An immutable wrapper for array of wide-characters that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:572
An immutable wrapper for floats that can serve as a distributable key object for caching.
Definition: CacheableBuiltins.hpp:537
This namespace contains all the Geode C++ API classes, enumerations and globals.
A mutable Cacheable stack wrapper that can serve as a distributable object for caching.
Definition: CacheableBuiltins.hpp:668
SharedArrayPtr(const SharedArrayPtr &other)
Constructor, given another SharedArrayPtr.
Definition: CacheableBuiltins.hpp:295