VMware GemFire Native C++ Reference  9.1
Region.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef GEODE_REGION_H_
4 #define GEODE_REGION_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 //#### Warning: DO NOT directly include Region.hpp, include Cache.hpp instead.
24 
25 #include "geode_globals.hpp"
26 #include "geode_types.hpp"
27 #include "CacheableKey.hpp"
28 #include "CacheableString.hpp"
29 #include "CacheStatistics.hpp"
30 #include "ExceptionTypes.hpp"
31 #include "CacheableString.hpp"
32 #include "UserData.hpp"
33 #include "CacheableBuiltins.hpp"
34 
39 #include "RegionEntry.hpp"
40 #include "CacheListener.hpp"
41 #include "PartitionResolver.hpp"
42 #include "CacheWriter.hpp"
43 #include "CacheLoader.hpp"
44 #include "RegionAttributes.hpp"
45 #include "AttributesMutator.hpp"
46 #include "AttributesFactory.hpp"
47 #include "CacheableKey.hpp"
48 #include "Query.hpp"
49 #define DEFAULT_RESPONSE_TIMEOUT 15
50 
51 namespace apache {
52 namespace geode {
53 namespace client {
90  public:
92  virtual const char* getName() const = 0;
93  // virtual uint64_t getUpdateReceived() const { return 0; };
94 
98  virtual const char* getFullPath() const = 0;
99 
103  virtual RegionPtr getParentRegion() const = 0;
104 
107  virtual RegionAttributesPtr getAttributes() const = 0;
108 
113  virtual AttributesMutatorPtr getAttributesMutator() const = 0;
114 
115  // virtual void updateAccessOrModifiedTime() = 0;
116 
117  virtual CacheStatisticsPtr getStatistics() const = 0;
118 
136  virtual void invalidateRegion(
137  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
138 
158  virtual void localInvalidateRegion(
159  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
160 
198  virtual void destroyRegion(
199  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
207  virtual void clear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
215  virtual void localClear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
216 
236  virtual void localDestroyRegion(
237  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
238 
241  virtual RegionPtr getSubregion(const char* path) = 0;
242 
244  virtual RegionPtr createSubregion(
245  const char* subregionName,
246  const RegionAttributesPtr& aRegionAttributes) = 0;
247 
255  virtual void subregions(const bool recursive, VectorOfRegion& sr) = 0;
256 
260  virtual RegionEntryPtr getEntry(const CacheableKeyPtr& key) = 0;
261 
263  template <class KEYTYPE>
264  inline RegionEntryPtr getEntry(const KEYTYPE& key) {
265  return getEntry(createKey(key));
266  }
267 
309  virtual CacheablePtr get(const CacheableKeyPtr& key,
310  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
311 
313  template <class KEYTYPE>
314  inline CacheablePtr get(const KEYTYPE& key,
315  const UserDataPtr& callbackArg = NULLPTR) {
316  return get(createKey(key), callbackArg);
317  }
318 
362  virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value,
363  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
364 
366  template <class KEYTYPE, class VALUETYPE>
367  inline void put(const KEYTYPE& key, const VALUETYPE& value,
368  const UserDataPtr& arg = NULLPTR) {
369  put(createKey(key), createValue(value), arg);
370  }
371 
373  template <class KEYTYPE>
374  inline void put(const KEYTYPE& key, const CacheablePtr& value,
375  const UserDataPtr& arg = NULLPTR) {
376  put(createKey(key), value, arg);
377  }
378 
380  template <class VALUETYPE>
381  inline void put(const CacheableKeyPtr& key, const VALUETYPE& value,
382  const UserDataPtr& arg = NULLPTR) {
383  put(key, createValue(value), arg);
384  }
385 
407  virtual void putAll(const HashMapOfCacheable& map,
408  uint32_t timeout = DEFAULT_RESPONSE_TIMEOUT,
409  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
410 
435  virtual void localPut(const CacheableKeyPtr& key, const CacheablePtr& value,
436  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
437 
439  template <class KEYTYPE, class VALUETYPE>
440  inline void localPut(const KEYTYPE& key, const VALUETYPE& value,
441  const UserDataPtr& arg = NULLPTR) {
442  localPut(createKey(key), createValue(value), arg);
443  }
444 
446  template <class KEYTYPE>
447  inline void localPut(const KEYTYPE& key, const CacheablePtr& value,
448  const UserDataPtr& arg = NULLPTR) {
449  localPut(createKey(key), value, arg);
450  }
451 
453  template <class VALUETYPE>
454  inline void localPut(const CacheableKeyPtr& key, const VALUETYPE& value,
455  const UserDataPtr& arg = NULLPTR) {
456  localPut(key, createValue(value), arg);
457  }
458 
505  virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value,
506  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
507 
509  template <class KEYTYPE, class VALUETYPE>
510  inline void create(const KEYTYPE& key, const VALUETYPE& value,
511  const UserDataPtr& arg = NULLPTR) {
512  create(createKey(key), createValue(value), arg);
513  }
514 
516  template <class KEYTYPE>
517  inline void create(const KEYTYPE& key, const CacheablePtr& value,
518  const UserDataPtr& arg = NULLPTR) {
519  create(createKey(key), value, arg);
520  }
521 
523  template <class VALUETYPE>
524  inline void create(const CacheableKeyPtr& key, const VALUETYPE& value,
525  const UserDataPtr& arg = NULLPTR) {
526  create(key, createValue(value), arg);
527  }
528 
554  virtual void localCreate(const CacheableKeyPtr& key,
555  const CacheablePtr& value,
556  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
557 
559  template <class KEYTYPE, class VALUETYPE>
560  inline void localCreate(const KEYTYPE& key, const VALUETYPE& value,
561  const UserDataPtr& arg = NULLPTR) {
562  localCreate(createKey(key), createValue(value), arg);
563  }
564 
566  template <class KEYTYPE>
567  inline void localCreate(const KEYTYPE& key, const CacheablePtr& value,
568  const UserDataPtr& arg = NULLPTR) {
569  localCreate(createKey(key), value, arg);
570  }
571 
573  template <class VALUETYPE>
574  inline void localCreate(const CacheableKeyPtr& key, const VALUETYPE& value,
575  const UserDataPtr& arg = NULLPTR) {
576  localCreate(key, createValue(value), arg);
577  }
578 
601  virtual void invalidate(const CacheableKeyPtr& key,
602  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
603 
605  template <class KEYTYPE>
606  inline void invalidate(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) {
607  invalidate(createKey(key), arg);
608  }
609 
630  virtual void localInvalidate(
631  const CacheableKeyPtr& key,
632  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
633 
635  template <class KEYTYPE>
636  inline void localInvalidate(const KEYTYPE& key,
637  const UserDataPtr& arg = NULLPTR) {
638  localInvalidate(createKey(key), arg);
639  }
640 
685  virtual void destroy(const CacheableKeyPtr& key,
686  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
687 
689  template <class KEYTYPE>
690  inline void destroy(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) {
691  destroy(createKey(key), arg);
692  }
693 
718  virtual void localDestroy(const CacheableKeyPtr& key,
719  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
720 
722  template <class KEYTYPE>
723  inline void localDestroy(const KEYTYPE& key,
724  const UserDataPtr& arg = NULLPTR) {
725  localDestroy(createKey(key), arg);
726  }
727 
776  virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value,
777  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
778 
780  template <class KEYTYPE, class VALUETYPE>
781  inline bool remove(const KEYTYPE& key, const VALUETYPE& value,
782  const UserDataPtr& arg = NULLPTR) {
783  return remove(createKey(key), createValue(value), arg);
784  }
785 
787  template <class KEYTYPE>
788  inline bool remove(const KEYTYPE& key, const CacheablePtr& value,
789  const UserDataPtr& arg = NULLPTR) {
790  return remove(createKey(key), value, arg);
791  }
792 
794  template <class VALUETYPE>
795  inline bool remove(const CacheableKeyPtr& key, const VALUETYPE& value,
796  const UserDataPtr& arg = NULLPTR) {
797  return remove(key, createValue(value), arg);
798  }
799 
800  bool remove(const CacheableKeyPtr& key) { return removeEx(key); }
801 
803  template <class KEYTYPE>
804  inline bool remove(const KEYTYPE& key) {
805  return remove(createKey(key));
806  }
807 
854  virtual bool removeEx(const CacheableKeyPtr& key,
855  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
856 
858  template <class KEYTYPE>
859  inline bool removeEx(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) {
860  return removeEx(createKey(key), arg);
861  }
862 
890  virtual bool localRemove(const CacheableKeyPtr& key,
891  const CacheablePtr& value,
892  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
893 
895  template <class KEYTYPE, class VALUETYPE>
896  inline bool localRemove(const KEYTYPE& key, const VALUETYPE& value,
897  const UserDataPtr& arg = NULLPTR) {
898  return localRemove(createKey(key), createValue(value), arg);
899  }
900 
902  template <class KEYTYPE>
903  inline bool localRemove(const KEYTYPE& key, const CacheablePtr& value,
904  const UserDataPtr& arg = NULLPTR) {
905  return localRemove(createKey(key), value, arg);
906  }
907 
909  template <class VALUETYPE>
910  inline bool localRemove(const CacheableKeyPtr& key, const VALUETYPE& value,
911  const UserDataPtr& arg = NULLPTR) {
912  return localRemove(key, createValue(value), arg);
913  }
914 
941  virtual bool localRemoveEx(
942  const CacheableKeyPtr& key,
943  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
944 
946  template <class KEYTYPE>
947  inline bool localRemoveEx(const KEYTYPE& key,
948  const UserDataPtr& arg = NULLPTR) {
949  return localRemoveEx(createKey(key), arg);
950  }
951 
956  virtual void keys(VectorOfCacheableKey& v) = 0;
957 
983  virtual void serverKeys(VectorOfCacheableKey& v) = 0;
984 
989  virtual void values(VectorOfCacheable& vc) = 0;
990 
991  virtual void entries(VectorOfRegionEntry& me, bool recursive) = 0;
992 
997  virtual RegionServicePtr getRegionService() const = 0;
998 
999  virtual bool isDestroyed() const = 0;
1000 
1006  virtual bool containsValueForKey(const CacheableKeyPtr& keyPtr) const = 0;
1007 
1014  template <class KEYTYPE>
1015  inline bool containsValueForKey(const KEYTYPE& key) const {
1016  return containsValueForKey(createKey(key));
1017  }
1018 
1024  virtual bool containsKey(const CacheableKeyPtr& keyPtr) const = 0;
1031  virtual bool containsKeyOnServer(const CacheableKeyPtr& keyPtr) const = 0;
1038  virtual void getInterestList(VectorOfCacheableKey& vlist) const = 0;
1045  virtual void getInterestListRegex(VectorOfCacheableString& vregex) const = 0;
1052  template <class KEYTYPE>
1053  inline bool containsKey(const KEYTYPE& key) const {
1054  return containsKey(createKey(key));
1055  }
1056 
1092  virtual void registerKeys(const VectorOfCacheableKey& keys,
1093  bool isDurable = false,
1094  bool getInitialValues = false,
1095  bool receiveValues = true) = 0;
1096 
1122  virtual void unregisterKeys(const VectorOfCacheableKey& keys) = 0;
1123 
1159  virtual void registerAllKeys(bool isDurable = false,
1160  VectorOfCacheableKeyPtr resultKeys = NULLPTR,
1161  bool getInitialValues = false,
1162  bool receiveValues = true) = 0;
1163 
1186  virtual void unregisterAllKeys() = 0;
1187 
1231  virtual void registerRegex(const char* regex, bool isDurable = false,
1232  VectorOfCacheableKeyPtr resultKeys = NULLPTR,
1233  bool getInitialValues = false,
1234  bool receiveValues = true) = 0;
1235 
1263  virtual void unregisterRegex(const char* regex) = 0;
1264 
1309  virtual void getAll(const VectorOfCacheableKey& keys,
1310  HashMapOfCacheablePtr values,
1311  HashMapOfExceptionPtr exceptions,
1312  bool addToLocalCache = false,
1313  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
1314 
1344  virtual SelectResultsPtr query(
1345  const char* predicate,
1346  uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) = 0;
1347 
1370  virtual bool existsValue(
1371  const char* predicate,
1372  uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) = 0;
1373 
1399  virtual SerializablePtr selectValue(
1400  const char* predicate,
1401  uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT) = 0;
1402 
1431  virtual void removeAll(const VectorOfCacheableKey& keys,
1432  const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
1433 
1438  virtual uint32_t size() = 0;
1439 
1440  virtual const PoolPtr& getPool() = 0;
1441 
1442  protected:
1443  Region();
1444  virtual ~Region();
1445 
1446  private:
1447  // Disallow copy constructor and assignment operator.
1448  Region(const Region&);
1449  Region& operator=(const Region&);
1450 };
1451 } // namespace client
1452 } // namespace geode
1453 } // namespace apache
1454 
1455 #endif // GEODE_REGION_H_
bool localRemove(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:910
bool localRemove(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:896
void localInvalidate(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:636
bool removeEx(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:859
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
A vector of Cacheable objects that also extends SharedBase for smart pointers.
Definition: VectorT.hpp:202
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:1015
void localCreate(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:574
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
bool localRemove(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:903
void create(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:510
Contains generic template definitions for Cacheable types and instantiations for built-in types...
bool localRemoveEx(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:947
void create(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:517
void destroy(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:690
void invalidate(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:606
void localDestroy(const KEYTYPE &key, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:723
RegionEntryPtr getEntry(const KEYTYPE &key)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:264
void localCreate(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:567
void put(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:367
void localCreate(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:560
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:40
A map of CacheableKey objects to Cacheable that also extends SharedBase for smart pointers...
Definition: HashMapT.hpp:174
Vector template type class.
Definition: VectorT.hpp:37
A vector of CacheableKey objects that also extends SharedBase for smart pointers. ...
Definition: VectorT.hpp:230
void localPut(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:454
void localPut(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:447
void put(const KEYTYPE &key, const CacheablePtr &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing key to be a const char*.
Definition: Region.hpp:374
void localPut(const KEYTYPE &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing both key and value to be a const char*.
Definition: Region.hpp:440
#define DEFAULT_QUERY_RESPONSE_TIMEOUT
default timeout for query response
Definition: geode_base.hpp:176
This class manages subregions and cached data.
Definition: Region.hpp:87
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:1053
void put(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:381
This namespace contains all the Geode C++ API classes, enumerations and globals.
void create(const CacheableKeyPtr &key, const VALUETYPE &value, const UserDataPtr &arg=::apache::geode::client::NullSharedBase::s_instancePtr)
Convenience method allowing value to be a const char*.
Definition: Region.hpp:524

Pivotal GemFire C++ Cache API Documentation