Pivotal GemFire Native Client Cache Reference  9.0.6
Region.hpp
Go to the documentation of this file.
1 #ifndef __GEMFIRE_REGION_H__
2 #define __GEMFIRE_REGION_H__
3 
4 /*=========================================================================
5 * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
6  * This product is protected by U.S. and international copyright
7  * and intellectual property laws. Pivotal products are covered by
8  * more patents listed at http://www.pivotal.io/patents.
9 *
10 * The specification of function behaviors is found in the corresponding .cpp file.
11 *
12 *========================================================================
13 */
14 
15 //#### Warning: DO NOT directly include Region.hpp, include Cache.hpp instead.
16 
17 #include "gfcpp_globals.hpp"
18 #include "gf_types.hpp"
19 #include "CacheableKey.hpp"
20 #include "CacheableString.hpp"
21 #include "CacheStatistics.hpp"
22 #include "ExceptionTypes.hpp"
23 #include "CacheableString.hpp"
24 #include "UserData.hpp"
25 #include "CacheableBuiltins.hpp"
26 
31 #include "RegionEntry.hpp"
32 #include "CacheListener.hpp"
33 #include "PartitionResolver.hpp"
34 #include "CacheWriter.hpp"
35 #include "CacheLoader.hpp"
36 #include "RegionAttributes.hpp"
37 #include "AttributesMutator.hpp"
38 #include "AttributesFactory.hpp"
39 #include "CacheableKey.hpp"
40 #include "Query.hpp"
41 #define DEFAULT_RESPONSE_TIMEOUT 15
42 
43 namespace gemfire {
76 
79  public:
80 
82  virtual const char* getName() const = 0;
83  //virtual uint64_t getUpdateReceived() const { return 0; };
84 
88  virtual const char* getFullPath() const = 0;
89 
93  virtual RegionPtr getParentRegion() const = 0;
94 
97  virtual RegionAttributesPtr getAttributes() const = 0;
98 
103  virtual AttributesMutatorPtr getAttributesMutator() const = 0;
104 
105  //virtual void updateAccessOrModifiedTime() = 0;
106 
107  virtual CacheStatisticsPtr getStatistics() const = 0;
108 
125  virtual void invalidateRegion(
126  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
127 
145  virtual void localInvalidateRegion(
146  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
147 
180  virtual void destroyRegion(
181  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
189  virtual void clear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
197  virtual void localClear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
198 
217  virtual void localDestroyRegion(
218  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
219 
221  virtual RegionPtr getSubregion(const char* path ) = 0;
222 
224  virtual RegionPtr createSubregion(const char* subregionName,
225  const RegionAttributesPtr& aRegionAttributes) = 0;
226 
232  virtual void subregions(const bool recursive, VectorOfRegion& sr) = 0;
233 
237  virtual RegionEntryPtr getEntry(const CacheableKeyPtr& key ) = 0;
238 
240  template< class KEYTYPE >
241  inline RegionEntryPtr getEntry( const KEYTYPE& key )
242  {
243  return getEntry( createKey( key ) );
244  }
245 
280  virtual CacheablePtr get(const CacheableKeyPtr& key,
281  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
282 
284  template<class KEYTYPE>
285  inline CacheablePtr get(const KEYTYPE& key,
286  const UserDataPtr& callbackArg = NULLPTR)
287  {
288  return get(createKey(key), callbackArg);
289  }
290 
291 
328  virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value,
329  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
330 
332  template< class KEYTYPE, class VALUETYPE >
333  inline void put( const KEYTYPE& key, const VALUETYPE& value,
334  const UserDataPtr& arg = NULLPTR)
335  {
336  put( createKey( key ), createValue( value ), arg );
337  }
338 
340  template< class KEYTYPE >
341  inline void put( const KEYTYPE& key, const CacheablePtr& value,
342  const UserDataPtr& arg = NULLPTR)
343  {
344  put( createKey( key ), value, arg );
345  }
346 
348  template< class VALUETYPE >
349  inline void put( const CacheableKeyPtr& key, const VALUETYPE& value,
350  const UserDataPtr& arg = NULLPTR)
351  {
352  put( key, createValue( value ), arg );
353  }
354 
374  virtual void putAll(const HashMapOfCacheable& map,
375  uint32_t timeout = DEFAULT_RESPONSE_TIMEOUT,
376  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
377 
399  virtual void localPut(const CacheableKeyPtr& key, const CacheablePtr& value,
400  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
401 
403  template<class KEYTYPE, class VALUETYPE>
404  inline void localPut(const KEYTYPE& key, const VALUETYPE& value,
405  const UserDataPtr& arg = NULLPTR)
406  {
407  localPut(createKey(key), createValue(value), arg);
408  }
409 
411  template<class KEYTYPE>
412  inline void localPut(const KEYTYPE& key, const CacheablePtr& value,
413  const UserDataPtr& arg = NULLPTR)
414  {
415  localPut(createKey(key), value, arg);
416  }
417 
419  template<class VALUETYPE>
420  inline void localPut(const CacheableKeyPtr& key, const VALUETYPE& value,
421  const UserDataPtr& arg = NULLPTR)
422  {
423  localPut(key, createValue(value), arg);
424  }
425 
426 
467  virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value,
468  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
469 
471  template< class KEYTYPE, class VALUETYPE >
472  inline void create( const KEYTYPE& key, const VALUETYPE& value,
473  const UserDataPtr& arg = NULLPTR)
474  {
475  create( createKey( key ), createValue( value ), arg );
476  }
477 
479  template< class KEYTYPE >
480  inline void create( const KEYTYPE& key, const CacheablePtr& value,
481  const UserDataPtr& arg = NULLPTR)
482  {
483  create( createKey( key ), value, arg );
484  }
485 
487  template< class VALUETYPE >
488  inline void create( const CacheableKeyPtr& key, const VALUETYPE& value,
489  const UserDataPtr& arg = NULLPTR)
490  {
491  create( key, createValue( value ), arg );
492  }
493 
494 
518  virtual void localCreate(const CacheableKeyPtr& key,
519  const CacheablePtr& value,
520  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
521 
523  template<class KEYTYPE, class VALUETYPE>
524  inline void localCreate(const KEYTYPE& key, const VALUETYPE& value,
525  const UserDataPtr& arg = NULLPTR)
526  {
527  localCreate(createKey(key), createValue(value), arg);
528  }
529 
531  template<class KEYTYPE>
532  inline void localCreate(const KEYTYPE& key, const CacheablePtr& value,
533  const UserDataPtr& arg = NULLPTR)
534  {
535  localCreate(createKey(key), value, arg);
536  }
537 
539  template<class VALUETYPE>
540  inline void localCreate(const CacheableKeyPtr& key, const VALUETYPE& value,
541  const UserDataPtr& arg = NULLPTR)
542  {
543  localCreate(key, createValue(value), arg);
544  }
545 
546 
567  virtual void invalidate(const CacheableKeyPtr& key,
568  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
569 
571  template< class KEYTYPE >
572  inline void invalidate( const KEYTYPE& key,
573  const UserDataPtr& arg = NULLPTR)
574  {
575  invalidate( createKey( key ), arg );
576  }
577 
597  virtual void localInvalidate(const CacheableKeyPtr& key,
598  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
599 
601  template< class KEYTYPE >
602  inline void localInvalidate( const KEYTYPE& key,
603  const UserDataPtr& arg = NULLPTR)
604  {
605  localInvalidate( createKey( key ), arg );
606  }
607 
608 
649  virtual void destroy(const CacheableKeyPtr& key,
650  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
651 
653  template< class KEYTYPE >
654  inline void destroy( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
655  {
656  destroy( createKey( key ), arg );
657  }
658 
681  virtual void localDestroy(const CacheableKeyPtr& key,
682  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
683 
685  template< class KEYTYPE >
686  inline void localDestroy( const KEYTYPE& key,
687  const UserDataPtr& arg = NULLPTR)
688  {
689  localDestroy( createKey( key ), arg );
690  }
691 
734  virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value,
735  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
736 
738  template< class KEYTYPE, class VALUETYPE >
739  inline bool remove( const KEYTYPE& key, const VALUETYPE& value,
740  const UserDataPtr& arg = NULLPTR)
741  {
742  return remove( createKey( key ), createValue( value ), arg );
743  }
744 
746  template< class KEYTYPE >
747  inline bool remove( const KEYTYPE& key, const CacheablePtr& value,
748  const UserDataPtr& arg = NULLPTR)
749  {
750  return remove( createKey( key ), value, arg );
751  }
752 
754  template< class VALUETYPE >
755  inline bool remove( const CacheableKeyPtr& key, const VALUETYPE& value,
756  const UserDataPtr& arg = NULLPTR)
757  {
758  return remove( key, createValue( value ), arg );
759  }
760 
761  bool remove(const CacheableKeyPtr& key)
762  {
763  return removeEx(key);
764  }
765 
767  template< class KEYTYPE>
768  inline bool remove( const KEYTYPE& key)
769  {
770  return remove( createKey( key ));
771  }
772 
814  virtual bool removeEx(const CacheableKeyPtr& key,
815  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
816 
818  template< class KEYTYPE >
819  inline bool removeEx( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
820  {
821  return removeEx( createKey( key ), arg );
822  }
823 
848  virtual bool localRemove(const CacheableKeyPtr& key, const CacheablePtr& value,
849  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
850 
851 
853  template< class KEYTYPE, class VALUETYPE >
854  inline bool localRemove( const KEYTYPE& key, const VALUETYPE& value,
855  const UserDataPtr& arg = NULLPTR)
856  {
857  return localRemove( createKey( key ), createValue( value ), arg );
858  }
859 
861  template< class KEYTYPE >
862  inline bool localRemove( const KEYTYPE& key, const CacheablePtr& value,
863  const UserDataPtr& arg = NULLPTR)
864  {
865  return localRemove( createKey( key ), value, arg );
866  }
867 
869  template< class VALUETYPE >
870  inline bool localRemove( const CacheableKeyPtr& key, const VALUETYPE& value,
871  const UserDataPtr& arg = NULLPTR)
872  {
873  return localRemove( key, createValue( value ), arg );
874  }
875 
900  virtual bool localRemoveEx(const CacheableKeyPtr& key,
901  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
902 
904  template< class KEYTYPE >
905  inline bool localRemoveEx( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
906  {
907  return localRemoveEx( createKey( key ), arg );
908  }
909 
910 
915  virtual void keys(VectorOfCacheableKey& v) = 0;
916 
938  virtual void serverKeys(VectorOfCacheableKey& v) = 0;
939 
944  virtual void values(VectorOfCacheable& vc) = 0;
945 
946  virtual void entries(VectorOfRegionEntry& me, bool recursive) = 0;
947 
953  virtual CachePtr getCache() const = 0;
954 
959  virtual RegionServicePtr getRegionService() const = 0;
960 
961  virtual bool isDestroyed() const = 0;
962 
968  virtual bool containsValueForKey(const CacheableKeyPtr& keyPtr) const = 0;
969 
976  template< class KEYTYPE >
977  inline bool containsValueForKey( const KEYTYPE& key ) const
978  {
979  return containsValueForKey( createKey( key ) );
980  }
981 
986  virtual bool containsKey(const CacheableKeyPtr& keyPtr) const = 0;
992  virtual bool containsKeyOnServer(const CacheableKeyPtr& keyPtr) const = 0;
998  virtual void getInterestList(VectorOfCacheableKey & vlist) const = 0;
1004  virtual void getInterestListRegex(VectorOfCacheableString & vregex) const = 0;
1011  template< class KEYTYPE >
1012  inline bool containsKey( const KEYTYPE& key ) const
1013  {
1014  return containsKey( createKey( key ) );
1015  }
1016 
1047  virtual void registerKeys(const VectorOfCacheableKey& keys,
1048  bool isDurable = false, bool getInitialValues = false,
1049  bool receiveValues = true) = 0;
1050 
1071  virtual void unregisterKeys(const VectorOfCacheableKey& keys) = 0;
1072 
1103  virtual void registerAllKeys(bool isDurable = false,
1104  VectorOfCacheableKeyPtr resultKeys = NULLPTR,
1105  bool getInitialValues = false, bool receiveValues = true) = 0;
1106 
1124  virtual void unregisterAllKeys()= 0;
1125 
1163  virtual void registerRegex(const char * regex, bool isDurable = false,
1164  VectorOfCacheableKeyPtr resultKeys = NULLPTR,
1165  bool getInitialValues = false, bool receiveValues = true) = 0;
1166 
1187  virtual void unregisterRegex(const char * regex)=0;
1188 
1229  virtual void getAll(const VectorOfCacheableKey& keys,
1230  HashMapOfCacheablePtr values, HashMapOfExceptionPtr exceptions,
1231  bool addToLocalCache = false,
1232  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
1233 
1258  virtual SelectResultsPtr query(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
1259 
1279  virtual bool existsValue(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
1280 
1301  virtual SerializablePtr selectValue(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
1302 
1327  virtual void removeAll(const VectorOfCacheableKey& keys, const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
1328 
1329 
1334  virtual uint32_t size() = 0;
1335 
1336  virtual const PoolPtr& getPool() =0;
1337 
1338  protected:
1339  Region();
1340  virtual ~Region();
1341 
1342  private:
1343  // Disallow copy constructor and assignment operator.
1344  Region(const Region &);
1345  Region & operator = (const Region &);
1346  };
1347 
1348 };//namespace gemfire
1349 
1350 
1351 #endif //ifndef __GEMFIRE_REGION_H__
1352 
Vector template type class.
Definition: VectorT.hpp:24
void create(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:472
void localPut(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:420
void create(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:480
void localPut(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:412
void localCreate(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:540
This class manages subregions and cached data.
Definition: Region.hpp:75
void invalidate(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:572
bool localRemove(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:862
Contains generic template definitions for Cacheable types and instantiations for built-in types...
#define DEFAULT_QUERY_RESPONSE_TIMEOUT
default timeout for query response
Definition: gf_base.hpp:214
A vector of CacheableKey objects that also extends SharedBase for smart pointers. ...
Definition: VectorT.hpp:300
bool localRemove(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:870
void localCreate(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:524
void put(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:349
void localPut(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:404
RegionEntryPtr getEntry(const KEYTYPE &key)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:241
bool containsKey(const KEYTYPE &key) const
Convenience method allowing key to be a const char* This operations checks for the key in the local c...
Definition: Region.hpp:1012
A vector of Cacheable objects that also extends SharedBase for smart pointers.
Definition: VectorT.hpp:269
void put(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:333
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
void localInvalidate(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:602
void put(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:341
A map of CacheableKey objects to Cacheable that also extends SharedBase for smart pointers...
Definition: HashMapT.hpp:240
void localDestroy(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:686
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:31
void create(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:488
void localCreate(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:532
bool removeEx(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:819
void destroy(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:654
bool localRemoveEx(const KEYTYPE &key, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:905
bool localRemove(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=gemfire::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:854
bool containsValueForKey(const KEYTYPE &key) const
Convenience method allowing key to be a const char* This operations checks for the value in the local...
Definition: Region.hpp:977

GemFire C++ Cache API Documentation