E:/gfcppsancout/product/include/gfcpp/RegionAttributes.hpp

Go to the documentation of this file.
00001 #ifndef __GEMFIRE_REGIONATTRIBUTES_H__
00002 #define __GEMFIRE_REGIONATTRIBUTES_H__
00003 /*=========================================================================
00004  * (c) Copyright 2002-2007, GemStone Systems, Inc. All Rights Reserved.
00005  * 1260 NW Waterhouse Ave., Suite 200,  Beaverton, OR 97006
00006  *========================================================================
00007  */
00008 
00013 #include "gfcpp_globals.hpp"
00014 #include "gf_types.hpp"
00015 #include "CacheLoader.hpp"
00016 #include "ScopeType.hpp"
00017 #include "ExpirationAttributes.hpp"
00018 #include "CacheWriter.hpp"
00019 #include "CacheListener.hpp"
00020 #include "PartitionResolver.hpp"
00021 #include "Properties.hpp"
00022 #include "Serializable.hpp"
00023 #include "DiskPolicyType.hpp"
00024 #include "PersistenceManager.hpp"
00025 
00026 
00027 namespace gemfire {
00028 class CacheImpl;
00029 
00050 class AttributesFactory;
00051 class AttributesMutator;
00052 class Cache;
00053 class Region;
00054 
00055 
00056 
00057 class CPPCACHE_EXPORT RegionAttributes: public Serializable  {
00058 
00062  public:
00063 
00069   CacheLoaderPtr getCacheLoader() ;
00070 
00076   CacheWriterPtr getCacheWriter() ;
00077 
00083   CacheListenerPtr getCacheListener() ;
00084 
00090   PartitionResolverPtr getPartitionResolver() ;
00091 
00095   int getRegionTimeToLive() ;
00096   ExpirationAction::Action getRegionTimeToLiveAction() ;
00097 
00102   int getRegionIdleTimeout() ;
00103   ExpirationAction::Action getRegionIdleTimeoutAction() ;
00104 
00108   int getEntryTimeToLive() ;
00109   ExpirationAction::Action getEntryTimeToLiveAction() ;
00110 
00114   int getEntryIdleTimeout() ;
00115   ExpirationAction::Action getEntryIdleTimeoutAction() ;
00116 
00117 
00118 
00123   ScopeType::Scope getScope() const;
00124 
00129   inline bool getCachingEnabled() const
00130   {
00131     return m_caching;
00132   }
00133 
00134   // MAP ATTRIBUTES
00135 
00136 
00140   int getInitialCapacity() const;
00141 
00145   float getLoadFactor() const;
00146 
00151   uint8_t getConcurrencyLevel() const;
00152 
00157   uint32_t getLruEntriesLimit( ) const;
00158 
00163   DiskPolicyType::PolicyType getDiskPolicy() const;
00164 
00168   const ExpirationAction::Action getLruEvictionAction( ) const;
00169 
00173   const char* getPoolName() const;
00174 
00175   /*destructor
00176    *
00177    */
00178   virtual ~RegionAttributes();
00179 
00181   virtual void toData(DataOutput& out) const;
00182 
00184   virtual Serializable* fromData( DataInput& in );
00185 
00187   static Serializable* createDeserializable( );
00188 
00190   virtual int32_t classId( ) const;
00191 
00193   virtual int8_t typeId( ) const;
00194 
00195   //return zero deliberately
00196   virtual uint32_t objectSize() const {
00197     return 0;
00198   }
00199 
00204   const char* getCacheLoaderLibrary();
00205 
00210   const char* getCacheLoaderFactory();
00211 
00216   const char* getCacheListenerLibrary();
00217 
00222   const char* getCacheListenerFactory();
00223 
00228   const char* getCacheWriterLibrary();
00229 
00234   const char* getCacheWriterFactory();
00235 
00240   const char* getPartitionResolverLibrary();
00241 
00246   const char* getPartitionResolverFactory();
00247 
00249   bool operator == ( const RegionAttributes& other ) const;
00250 
00252   bool operator != ( const RegionAttributes& other ) const;
00253 
00258   void validateSerializableAttributes( );
00259 
00263   const char* getEndpoints();
00264 
00268   bool getClientNotificationEnabled() const;
00269 
00274   const char* getPersistenceLibrary();
00275 
00280   const char* getPersistenceFactory();
00281 
00285   PropertiesPtr getPersistenceProperties();
00286 
00292   PersistenceManagerPtr getPersistenceManager() ;
00293 
00299   const char* getPoolName() { return m_poolName; }
00300   bool getCloningEnabled( ) { return m_isClonable; }
00301 
00307   bool getConcurrencyChecksEnabled() { return m_isConcurrencyChecksEnabled; }
00308   private:
00309   //Helper function that safely compares two attribute string
00310   //taking into consideration the fact the one or the other
00311   //might be NULL
00312   static int32_t compareStringAttribute(char* attributeA, char* attributeB);
00313 
00314   //Helper function that safely copies one string attribute to
00315   //another.
00316   static void copyStringAttribute(char*& lhs, const char* rhs);
00317 
00318   void setCacheListener(const char* libpath, const char* factoryFuncName);
00319   void setCacheLoader  (const char* libpath, const char* factoryFuncName);
00320   void setCacheWriter  (const char* libpath, const char* factoryFuncName);
00321   void setPartitionResolver(const char* libpath, const char* factoryFuncName);
00322   void setPersistenceManager(const char* lib, const char* func, const PropertiesPtr& config);
00323   void setEndpoints( const char* endpoints );
00324   void setPoolName( const char* poolName );
00325   void setCloningEnabled( bool isClonable );
00326   void setCachingEnabled( bool enable);
00327   void setLruEntriesLimit(int limit);
00328   void setDiskPolicy(DiskPolicyType::PolicyType diskPolicy);
00329   void setScope(ScopeType::Scope scope);
00330   void setConcurrencyChecksEnabled( bool enable );
00331   inline bool getEntryExpiryEnabled() const
00332   {
00333     return (m_entryTimeToLive != 0 || m_entryIdleTimeout != 0);
00334   }
00335 
00336   inline bool getRegionExpiryEnabled() const
00337   {
00338     return (m_regionTimeToLive != 0 || m_regionIdleTimeout != 0);
00339   }
00340   
00341 
00342   //will be created by the factory
00343    RegionAttributes(const RegionAttributes& rhs);
00344    RegionAttributes();
00345 
00346    ExpirationAction::Action m_regionTimeToLiveExpirationAction;
00347    ExpirationAction::Action m_regionIdleTimeoutExpirationAction;
00348    ExpirationAction::Action m_entryTimeToLiveExpirationAction;
00349    ExpirationAction::Action m_entryIdleTimeoutExpirationAction;
00350    ExpirationAction::Action m_lruEvictionAction;
00351    CacheWriterPtr m_cacheWriter;
00352    CacheLoaderPtr m_cacheLoader;
00353    CacheListenerPtr m_cacheListener;
00354    PartitionResolverPtr m_partitionResolver;
00355    uint32_t m_lruEntriesLimit;
00356    bool m_caching;
00357    uint32_t  m_maxValueDistLimit;
00358    uint32_t m_entryIdleTimeout;
00359    uint32_t m_entryTimeToLive;
00360    uint32_t m_regionIdleTimeout;
00361    uint32_t m_regionTimeToLive;
00362    ScopeType::Scope m_scope;
00363    uint32_t m_initialCapacity;
00364    float m_loadFactor;
00365    uint8_t m_concurrencyLevel;
00366    char* m_cacheLoaderLibrary;
00367    char* m_cacheWriterLibrary;
00368    char* m_cacheListenerLibrary;
00369    char* m_partitionResolverLibrary;
00370    char* m_cacheLoaderFactory;
00371    char* m_cacheWriterFactory;
00372    char* m_cacheListenerFactory;
00373    char* m_partitionResolverFactory;
00374    DiskPolicyType::PolicyType m_diskPolicy;
00375    char* m_endpoints;
00376    bool m_clientNotificationEnabled;
00377    char* m_persistenceLibrary;
00378    char* m_persistenceFactory;
00379    PropertiesPtr m_persistenceProperties;
00380    PersistenceManagerPtr m_persistenceManager;
00381    char *m_poolName;
00382    bool m_isClonable;
00383    bool m_isConcurrencyChecksEnabled;
00384   friend class AttributesFactory;
00385   friend class AttributesMutator;
00386   friend class Cache;
00387   friend class CacheImpl;
00388   friend class Region;
00389   friend class RegionInternal;
00390   friend class RegionXmlCreation;
00391 
00392   private:
00393         const RegionAttributes& operator=( const RegionAttributes& );
00394 
00395 };
00396 
00397 } //namespace gemfire
00398 
00399 #endif //ifndef __GEMFIRE_REGIONATTRIBUTES_H__

GemFire C++ Cache API Documentation