00001 #ifndef __GEMFIRE_REGION_H__
00002 #define __GEMFIRE_REGION_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "gfcpp_globals.hpp"
00018 #include "gf_types.hpp"
00019 #include "CacheableKey.hpp"
00020 #include "CacheableString.hpp"
00021 #include "CacheStatistics.hpp"
00022 #include "ExceptionTypes.hpp"
00023 #include "CacheableString.hpp"
00024 #include "UserData.hpp"
00025 #include "CacheableBuiltins.hpp"
00026
00031 #include "RegionEntry.hpp"
00032 #include "CacheListener.hpp"
00033 #include "PartitionResolver.hpp"
00034 #include "CacheWriter.hpp"
00035 #include "CacheLoader.hpp"
00036 #include "RegionAttributes.hpp"
00037 #include "AttributesMutator.hpp"
00038 #include "AttributesFactory.hpp"
00039 #include "CacheableKey.hpp"
00040 #include "Query.hpp"
00041 #define DEFAULT_RESPONSE_TIMEOUT 15
00042
00043 namespace gemfire {
00075 class CPPCACHE_EXPORT Region : public SharedBase {
00076
00079 public:
00080
00082 virtual const char* getName() const = 0;
00083
00084
00088 virtual const char* getFullPath() const = 0;
00089
00093 virtual RegionPtr getParentRegion() const = 0;
00094
00097 virtual RegionAttributesPtr getAttributes() const = 0;
00098
00103 virtual AttributesMutatorPtr getAttributesMutator() const = 0;
00104
00105
00106
00107 virtual CacheStatisticsPtr getStatistics() const = 0;
00108
00125 virtual void invalidateRegion(
00126 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00127
00145 virtual void localInvalidateRegion(
00146 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00147
00180 virtual void destroyRegion(
00181 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00189 virtual void clear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00197 virtual void localClear(const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00198
00217 virtual void localDestroyRegion(
00218 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00219
00221 virtual RegionPtr getSubregion(const char* path ) = 0;
00222
00224 virtual RegionPtr createSubregion(const char* subregionName,
00225 const RegionAttributesPtr& aRegionAttributes) = 0;
00226
00232 virtual void subregions(const bool recursive, VectorOfRegion& sr) = 0;
00233
00237 virtual RegionEntryPtr getEntry(const CacheableKeyPtr& key ) = 0;
00238
00240 template< class KEYTYPE >
00241 inline RegionEntryPtr getEntry( const KEYTYPE& key )
00242 {
00243 return getEntry( createKey( key ) );
00244 }
00245
00280 virtual CacheablePtr get(const CacheableKeyPtr& key,
00281 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00282
00284 template<class KEYTYPE>
00285 inline CacheablePtr get(const KEYTYPE& key,
00286 const UserDataPtr& callbackArg = NULLPTR)
00287 {
00288 return get(createKey(key), callbackArg);
00289 }
00290
00291
00328 virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value,
00329 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00330
00332 template< class KEYTYPE, class VALUETYPE >
00333 inline void put( const KEYTYPE& key, const VALUETYPE& value,
00334 const UserDataPtr& arg = NULLPTR)
00335 {
00336 put( createKey( key ), createValue( value ), arg );
00337 }
00338
00340 template< class KEYTYPE >
00341 inline void put( const KEYTYPE& key, const CacheablePtr& value,
00342 const UserDataPtr& arg = NULLPTR)
00343 {
00344 put( createKey( key ), value, arg );
00345 }
00346
00348 template< class VALUETYPE >
00349 inline void put( const CacheableKeyPtr& key, const VALUETYPE& value,
00350 const UserDataPtr& arg = NULLPTR)
00351 {
00352 put( key, createValue( value ), arg );
00353 }
00354
00374 virtual void putAll(const HashMapOfCacheable& map,
00375 uint32_t timeout = DEFAULT_RESPONSE_TIMEOUT,
00376 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00377
00399 virtual void localPut(const CacheableKeyPtr& key, const CacheablePtr& value,
00400 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00401
00403 template<class KEYTYPE, class VALUETYPE>
00404 inline void localPut(const KEYTYPE& key, const VALUETYPE& value,
00405 const UserDataPtr& arg = NULLPTR)
00406 {
00407 localPut(createKey(key), createValue(value), arg);
00408 }
00409
00411 template<class KEYTYPE>
00412 inline void localPut(const KEYTYPE& key, const CacheablePtr& value,
00413 const UserDataPtr& arg = NULLPTR)
00414 {
00415 localPut(createKey(key), value, arg);
00416 }
00417
00419 template<class VALUETYPE>
00420 inline void localPut(const CacheableKeyPtr& key, const VALUETYPE& value,
00421 const UserDataPtr& arg = NULLPTR)
00422 {
00423 localPut(key, createValue(value), arg);
00424 }
00425
00426
00467 virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value,
00468 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00469
00471 template< class KEYTYPE, class VALUETYPE >
00472 inline void create( const KEYTYPE& key, const VALUETYPE& value,
00473 const UserDataPtr& arg = NULLPTR)
00474 {
00475 create( createKey( key ), createValue( value ), arg );
00476 }
00477
00479 template< class KEYTYPE >
00480 inline void create( const KEYTYPE& key, const CacheablePtr& value,
00481 const UserDataPtr& arg = NULLPTR)
00482 {
00483 create( createKey( key ), value, arg );
00484 }
00485
00487 template< class VALUETYPE >
00488 inline void create( const CacheableKeyPtr& key, const VALUETYPE& value,
00489 const UserDataPtr& arg = NULLPTR)
00490 {
00491 create( key, createValue( value ), arg );
00492 }
00493
00494
00518 virtual void localCreate(const CacheableKeyPtr& key,
00519 const CacheablePtr& value,
00520 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00521
00523 template<class KEYTYPE, class VALUETYPE>
00524 inline void localCreate(const KEYTYPE& key, const VALUETYPE& value,
00525 const UserDataPtr& arg = NULLPTR)
00526 {
00527 localCreate(createKey(key), createValue(value), arg);
00528 }
00529
00531 template<class KEYTYPE>
00532 inline void localCreate(const KEYTYPE& key, const CacheablePtr& value,
00533 const UserDataPtr& arg = NULLPTR)
00534 {
00535 localCreate(createKey(key), value, arg);
00536 }
00537
00539 template<class VALUETYPE>
00540 inline void localCreate(const CacheableKeyPtr& key, const VALUETYPE& value,
00541 const UserDataPtr& arg = NULLPTR)
00542 {
00543 localCreate(key, createValue(value), arg);
00544 }
00545
00546
00567 virtual void invalidate(const CacheableKeyPtr& key,
00568 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00569
00571 template< class KEYTYPE >
00572 inline void invalidate( const KEYTYPE& key,
00573 const UserDataPtr& arg = NULLPTR)
00574 {
00575 invalidate( createKey( key ), arg );
00576 }
00577
00597 virtual void localInvalidate(const CacheableKeyPtr& key,
00598 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00599
00601 template< class KEYTYPE >
00602 inline void localInvalidate( const KEYTYPE& key,
00603 const UserDataPtr& arg = NULLPTR)
00604 {
00605 localInvalidate( createKey( key ), arg );
00606 }
00607
00608
00649 virtual void destroy(const CacheableKeyPtr& key,
00650 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00651
00653 template< class KEYTYPE >
00654 inline void destroy( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
00655 {
00656 destroy( createKey( key ), arg );
00657 }
00658
00681 virtual void localDestroy(const CacheableKeyPtr& key,
00682 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00683
00685 template< class KEYTYPE >
00686 inline void localDestroy( const KEYTYPE& key,
00687 const UserDataPtr& arg = NULLPTR)
00688 {
00689 localDestroy( createKey( key ), arg );
00690 }
00691
00734 virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value,
00735 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00736
00738 template< class KEYTYPE, class VALUETYPE >
00739 inline bool remove( const KEYTYPE& key, const VALUETYPE& value,
00740 const UserDataPtr& arg = NULLPTR)
00741 {
00742 return remove( createKey( key ), createValue( value ), arg );
00743 }
00744
00746 template< class KEYTYPE >
00747 inline bool remove( const KEYTYPE& key, const CacheablePtr& value,
00748 const UserDataPtr& arg = NULLPTR)
00749 {
00750 return remove( createKey( key ), value, arg );
00751 }
00752
00754 template< class VALUETYPE >
00755 inline bool remove( const CacheableKeyPtr& key, const VALUETYPE& value,
00756 const UserDataPtr& arg = NULLPTR)
00757 {
00758 return remove( key, createValue( value ), arg );
00759 }
00760
00761 bool remove(const CacheableKeyPtr& key)
00762 {
00763 return removeEx(key);
00764 }
00765
00767 template< class KEYTYPE>
00768 inline bool remove( const KEYTYPE& key)
00769 {
00770 return remove( createKey( key ));
00771 }
00772
00814 virtual bool removeEx(const CacheableKeyPtr& key,
00815 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00816
00818 template< class KEYTYPE >
00819 inline bool removeEx( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
00820 {
00821 return removeEx( createKey( key ), arg );
00822 }
00823
00848 virtual bool localRemove(const CacheableKeyPtr& key, const CacheablePtr& value,
00849 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00850
00851
00853 template< class KEYTYPE, class VALUETYPE >
00854 inline bool localRemove( const KEYTYPE& key, const VALUETYPE& value,
00855 const UserDataPtr& arg = NULLPTR)
00856 {
00857 return localRemove( createKey( key ), createValue( value ), arg );
00858 }
00859
00861 template< class KEYTYPE >
00862 inline bool localRemove( const KEYTYPE& key, const CacheablePtr& value,
00863 const UserDataPtr& arg = NULLPTR)
00864 {
00865 return localRemove( createKey( key ), value, arg );
00866 }
00867
00869 template< class VALUETYPE >
00870 inline bool localRemove( const CacheableKeyPtr& key, const VALUETYPE& value,
00871 const UserDataPtr& arg = NULLPTR)
00872 {
00873 return localRemove( key, createValue( value ), arg );
00874 }
00875
00900 virtual bool localRemoveEx(const CacheableKeyPtr& key,
00901 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
00902
00904 template< class KEYTYPE >
00905 inline bool localRemoveEx( const KEYTYPE& key, const UserDataPtr& arg = NULLPTR)
00906 {
00907 return localRemoveEx( createKey( key ), arg );
00908 }
00909
00910
00915 virtual void keys(VectorOfCacheableKey& v) = 0;
00916
00938 virtual void serverKeys(VectorOfCacheableKey& v) = 0;
00939
00944 virtual void values(VectorOfCacheable& vc) = 0;
00945
00946 virtual void entries(VectorOfRegionEntry& me, bool recursive) = 0;
00947
00953 virtual CachePtr getCache() const = 0;
00954
00959 virtual RegionServicePtr getRegionService() const = 0;
00960
00961 virtual bool isDestroyed() const = 0;
00962
00968 virtual bool containsValueForKey(const CacheableKeyPtr& keyPtr) const = 0;
00969
00976 template< class KEYTYPE >
00977 inline bool containsValueForKey( const KEYTYPE& key ) const
00978 {
00979 return containsValueForKey( createKey( key ) );
00980 }
00981
00986 virtual bool containsKey(const CacheableKeyPtr& keyPtr) const = 0;
00992 virtual bool containsKeyOnServer(const CacheableKeyPtr& keyPtr) const = 0;
00998 virtual void getInterestList(VectorOfCacheableKey & vlist) const = 0;
01004 virtual void getInterestListRegex(VectorOfCacheableString & vregex) const = 0;
01011 template< class KEYTYPE >
01012 inline bool containsKey( const KEYTYPE& key ) const
01013 {
01014 return containsKey( createKey( key ) );
01015 }
01016
01047 virtual void registerKeys(const VectorOfCacheableKey& keys,
01048 bool isDurable = false, bool getInitialValues = false,
01049 bool receiveValues = true) = 0;
01050
01071 virtual void unregisterKeys(const VectorOfCacheableKey& keys) = 0;
01072
01103 virtual void registerAllKeys(bool isDurable = false,
01104 VectorOfCacheableKeyPtr resultKeys = NULLPTR,
01105 bool getInitialValues = false, bool receiveValues = true) = 0;
01106
01124 virtual void unregisterAllKeys()= 0;
01125
01163 virtual void registerRegex(const char * regex, bool isDurable = false,
01164 VectorOfCacheableKeyPtr resultKeys = NULLPTR,
01165 bool getInitialValues = false, bool receiveValues = true) = 0;
01166
01187 virtual void unregisterRegex(const char * regex)=0;
01188
01229 virtual void getAll(const VectorOfCacheableKey& keys,
01230 HashMapOfCacheablePtr values, HashMapOfExceptionPtr exceptions,
01231 bool addToLocalCache = false,
01232 const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
01233
01258 virtual SelectResultsPtr query(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
01259
01279 virtual bool existsValue(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
01280
01301 virtual SerializablePtr selectValue(const char * predicate, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT)=0;
01302
01327 virtual void removeAll(const VectorOfCacheableKey& keys, const UserDataPtr& aCallbackArgument = NULLPTR) = 0;
01328
01329
01334 virtual uint32_t size() = 0;
01335
01336 virtual const PoolPtr& getPool() =0;
01337
01338 protected:
01339 Region();
01340 virtual ~Region();
01341
01342 private:
01343
01344 Region(const Region &);
01345 Region & operator = (const Region &);
01346 };
01347
01348 };
01349
01350
01351 #endif //ifndef __GEMFIRE_REGION_H__
01352