1 #ifndef _GEMFIRE_CACHEABLE_BUILTINS_HPP_ 2 #define _GEMFIRE_CACHEABLE_BUILTINS_HPP_ 19 #include "Serializer.hpp" 20 #include "CacheableKeys.hpp" 28 extern int gf_sprintf(
char* buffer,
const char* fmt, ...);
31 extern int gf_snprintf(
char* buffer, int32_t maxLength,
const char* fmt, ...);
34 template<
typename TObj, int8_t TYPEID,
const char* TYPENAME,
35 const char* SPRINTFSYM, int32_t STRSIZE>
42 m_value(gemfire::serializer::zeroObject<TObj>())
63 gemfire::serializer::writeObject(output, m_value);
69 gemfire::serializer::readObject(input, m_value);
98 char buffer[STRSIZE + 1];
108 return gemfire::serializer::hashcode(m_value);
114 if (other.
typeId() != TYPEID) {
119 return gemfire::serializer::equals(m_value, otherValue.m_value);
125 return gemfire::serializer::equals(m_value, other);
132 virtual int32_t
logString(
char* buffer, int32_t maxLength)
const 135 gf_sprintf(fmt,
"%s( %s )", TYPENAME, SPRINTFSYM);
136 return gf_snprintf(buffer, maxLength, fmt, m_value);
157 template<
typename TObj>
158 inline void copyArray(TObj* dest,
const TObj* src, int32_t length)
160 memcpy(dest, src, length *
sizeof(TObj));
167 template<
typename TObj>
171 for (int32_t index = 0; index < length; index++) {
172 dest[index] = src[index];
180 template<
typename TObj,
int8_t TYPEID>
184 for (int32_t index = 0; index < length; index++) {
185 dest[index] = src[index];
190 template<
typename TObj,
int8_t TYPEID>
199 m_value(NULL), m_length(0)
207 GF_NEW(m_value, TObj[length]);
212 m_value(value), m_length(length)
217 m_value(NULL), m_length(length)
220 GF_NEW(m_value, TObj[length]);
234 m_value(other.m_value), m_length(other.m_length)
258 inline TObj operator [](uint32_t index)
const 260 if ((int32_t) index >= m_length) {
261 throw OutOfRangeException(
262 "CacheableArray::operator[]: Index out of range.");
264 return m_value[index];
272 gemfire::serializer::writeObject(output, m_value, m_length);
279 gemfire::serializer::readObject(input, m_value, m_length);
316 + gemfire::serializer::objectSize(m_value, m_length));
324 template<
typename TObj,
int8_t TYPEID>
358 template<
typename TOther,
int8_t OTHERID>
365 template<
typename TOther>
372 inline TObj operator [](uint32_t index)
const 386 template<
typename TBase,
int8_t TYPEID>
408 gemfire::serializer::writeObject(output, *
this);
414 gemfire::serializer::readObject(input, *
this);
451 gemfire::serializer::objectSize(*
this));
457 #define TEMPLATE_EXPORT template class 459 #ifdef BUILD_CPPCACHE 460 #define TEMPLATE_EXPORT template class CPPCACHE_EXPORT 462 #define TEMPLATE_EXPORT extern template class CPPCACHE_EXPORT 469 #pragma warning(disable: 4231) 472 #define _GF_CACHEABLE_KEY_TYPE_DEF_(p, k, sz) \ 473 extern const char tName_##k []; \ 474 extern const char tStr_##k []; \ 475 TEMPLATE_EXPORT CacheableKeyType<p, GemfireTypeIds::k, \ 476 tName_##k, tStr_##k, sz>; \ 477 typedef CacheableKeyType<p, GemfireTypeIds::k, \ 478 tName_##k, tStr_##k, sz> _##k; \ 479 class CPPCACHE_EXPORT k; \ 480 typedef SharedPtr<k> k##Ptr; 483 #define _GF_CACHEABLE_KEY_TYPE_(p, k, sz) \ 484 class CPPCACHE_EXPORT k: public _##k \ 487 inline k() : _##k() { } \ 488 inline k(const p value) : _##k(value) { } \ 491 static Serializable* createDeserializable() { \ 495 inline static k##Ptr create() { \ 496 return k##Ptr(new k()); \ 499 inline static k##Ptr create(const p value) { \ 500 return k##Ptr(new k(value)); \ 503 inline CacheableKeyPtr createKey(const p value) { \ 504 return k::create(value); \ 506 inline CacheablePtr createValue(const p value) { \ 507 return k::create(value); \ 511 #define _GF_CACHEABLE_ARRAY_TYPE_DEF_(p, c) \ 512 TEMPLATE_EXPORT CacheableArrayType<p, GemfireTypeIds::c>; \ 513 typedef CacheableArrayType<p, GemfireTypeIds::c> _##c; \ 514 class CPPCACHE_EXPORT c; \ 515 typedef SharedArrayPtr<p, GemfireTypeIds::c> c##Ptr; 518 #define _GF_CACHEABLE_ARRAY_TYPE_(p, c) \ 519 class CPPCACHE_EXPORT c: public _##c \ 522 inline c() : _##c() { } \ 523 inline c(int32_t length) : _##c(length) { } \ 524 inline c(p* value, int32_t length) : _##c(value, length) { } \ 525 inline c(const p* value, int32_t length, bool copy) : \ 526 _##c(value, length, true) { } \ 530 c& operator =(const c& other); \ 533 static Serializable* createDeserializable() { \ 537 inline static c##Ptr create() { \ 538 return c##Ptr(new c()); \ 541 inline static c##Ptr create(int32_t length) { \ 542 return c##Ptr(new c(length)); \ 545 inline static c##Ptr create(const p* value, int32_t length) { \ 546 return (value != NULL ? c##Ptr(new c(value, length, true)) : \ 557 inline static c##Ptr createNoCopy(p* value, int32_t length) { \ 558 return (value != NULL ? c##Ptr(new c(value, length)) : \ 564 #define _GF_CACHEABLE_CONTAINER_TYPE_DEF_(p, c) \ 565 TEMPLATE_EXPORT CacheableContainerType<p, GemfireTypeIds::c>; \ 566 typedef CacheableContainerType<p, GemfireTypeIds::c> _##c; \ 567 class CPPCACHE_EXPORT c; \ 568 typedef SharedPtr<c> c##Ptr; 571 #define _GF_CACHEABLE_CONTAINER_TYPE_(p, c) \ 572 class CPPCACHE_EXPORT c: public _##c \ 575 inline c() : _##c() { } \ 576 inline c(const int32_t n) : _##c(n) { } \ 579 typedef p::Iterator Iterator; \ 581 static Serializable* createDeserializable() { \ 585 inline static c##Ptr create() { \ 586 return c##Ptr(new c()); \ 589 inline static c##Ptr create(const int32_t n) { \ 590 return c##Ptr(new c(n)); \ 662 _GF_CACHEABLE_ARRAY_TYPE_DEF_(
wchar_t,
CharArray);
799 #endif // _GEMFIRE_CACHEABLE_BUILTINS_HPP_ A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:783
An immutable wrapper for array of booleans that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:610
virtual void toData(DataOutput &output) const
Serialize this object to the given DataOutput.
Definition: CacheableBuiltins.hpp:406
Vector template type class.
Definition: VectorT.hpp:24
Class encapsulating a NULL SharedBase smart pointer.
Definition: SharedBase.hpp:78
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:62
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:313
A mutable Cacheable stack wrapper that can serve as a distributable object for caching.
Definition: CacheableBuiltins.hpp:764
TObj value() const
Gets the contained value.
Definition: CacheableBuiltins.hpp:53
An immutable wrapper for 16-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:638
SharedArrayPtr()
Default constructor.
Definition: CacheableBuiltins.hpp:334
void copyArray(TObj *dest, const TObj *src, int32_t length)
Function to copy an array from source to destination.
Definition: CacheableBuiltins.hpp:158
An immutable wrapper for bytes that can serve as a distributable key object for caching.
Definition: CacheableBuiltins.hpp:617
Represents a cacheable key.
Definition: CacheableKey.hpp:23
A mutable CacheableKey hash set wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:795
Template class for CacheableArrayType SharedPtr's that adds [] operator.
Definition: CacheableBuiltins.hpp:154
An immutable wrapper for array of 64-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:711
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:147
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 int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:289
Serializable * fromData(DataInput &input)
Deserialize self.
Definition: CacheableBuiltins.hpp:379
An immutable wrapper for array of floats that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:690
An immutable wrapper for 32-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:645
virtual bool operator==(const CacheableKey &other) const
Return true if this key matches other.
Definition: CacheableBuiltins.hpp:112
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:90
An immutable wrapper for array of doubles that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:683
A mutable CacheableKey hash set wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:742
A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:771
Template class for array of primitive types.
Definition: CacheableBuiltins.hpp:191
virtual uint32_t hashcode() const
Return the hashcode for this key.
Definition: CacheableBuiltins.hpp:106
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
SharedArrayPtr(const TArray *ptr)
Constructor, given a pointer to array.
Definition: CacheableBuiltins.hpp:340
HashMap of TKEY to TVAL.
Definition: HashMapT.hpp:26
An immutable wrapper for array of 32-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:704
SharedArrayPtr(const SharedArrayPtr &other)
Constructor, given another SharedArrayPtr.
Definition: CacheableBuiltins.hpp:352
virtual Serializable * fromData(DataInput &input)
Deserialize this object from given DataInput.
Definition: CacheableBuiltins.hpp:67
#define GF_SAFE_DELETE_ARRAY(x)
Deletes array x only if it exists.
Definition: gf_base.hpp:334
An immutable wrapper for array of 16-bit integers that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:697
Template class for container Cacheable types.
Definition: CacheableBuiltins.hpp:387
virtual Serializable * fromData(DataInput &input)
Deserialize this object from the given DataInput.
Definition: CacheableBuiltins.hpp:276
An immutable wrapper for array of wide-characters that can serve as a distributable object for cachin...
Definition: CacheableBuiltins.hpp:667
An immutable wrapper for booleans that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:603
An immutable wrapper for 64-bit integers that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:652
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:424
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:300
A mutable Cacheable array list wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:757
An immutable wrapper for floats that can serve as a distributable key object for caching.
Definition: CacheableBuiltins.hpp:631
virtual Serializable * fromData(DataInput &input)
Deserialize this object from the given DataInput.
Definition: CacheableBuiltins.hpp:412
A mutable CacheableKey to Serializable hash map that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:735
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:39
An immutable wrapper for byte arrays that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:676
virtual int8_t typeId() const
return the typeId byte of the instance being serialized.
virtual void toData(DataOutput &output) const
Serialize this object to given DataOutput.
Definition: CacheableBuiltins.hpp:61
virtual CacheableStringPtr toString() const
Return a string representation of the object.
Definition: CacheableBuiltins.hpp:96
SharedArrayPtr(const SharedArrayPtr< TOther, OTHERID > &other)
Constructor, given another kind of SharedArrayPtr.
Definition: CacheableBuiltins.hpp:359
virtual int32_t classId() const
Return the classId of the instance being serialized.
Definition: CacheableBuiltins.hpp:79
virtual uint32_t objectSize() const
Return the size in bytes of the instance being serialized.
Definition: CacheableBuiltins.hpp:448
virtual int8_t typeId() const
Return the typeId byte of the instance being serialized.
Definition: CacheableBuiltins.hpp:435
An immutable wrapper for array of strings that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:718
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:132
A mutable Cacheable array list wrapper that can serve as a distributable object for caching...
Definition: CacheableBuiltins.hpp:749
SharedArrayPtr(const SharedPtr< TOther > &other)
Constructor, given another SharedPtr.
Definition: CacheableBuiltins.hpp:366
An immutable wrapper for wide-characters that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:659
A mutable Cacheable vector wrapper that can serve as a distributable object for caching.
Definition: CacheableBuiltins.hpp:728
int gf_snprintf(char *buffer, int32_t maxLength, const char *fmt,...)
snprintf implementation.
An immutable wrapper for doubles that can serve as a distributable key object for caching...
Definition: CacheableBuiltins.hpp:624
virtual void toData(DataOutput &output) const
Serialize this object to the given DataOutput.
Definition: CacheableBuiltins.hpp:270
#define GF_NEW(v, stmt)
Allocates x and throws OutOfMemoryException if it fails.
Definition: gf_base.hpp:315
SharedArrayPtr(const NullSharedBase *ptr)
Constructor, given a null SharedBase.
Definition: CacheableBuiltins.hpp:346
int gf_sprintf(char *buffer, const char *fmt,...)
sprintf implementation.
Template CacheableKey class for primitive types.
Definition: CacheableBuiltins.hpp:36
const TObj * value() const
Get the underlying array.
Definition: CacheableBuiltins.hpp:246
HashSet of TKEY.
Definition: HashSetT.hpp:24
int32_t length() const
Get the length of the array.
Definition: CacheableBuiltins.hpp:252