H:/gfcppsancout/product/include/gfcpp/SharedBase.hpp

Go to the documentation of this file.
00001 #ifndef _GEMFIRE_SHAREDBASE_HPP_
00002 #define _GEMFIRE_SHAREDBASE_HPP_
00003 
00004 
00005 // SharedBase.hpp     -*- mode: c++ -*-
00006 
00007 
00008 /*=========================================================================
00009  * (c) Copyright 2004-2007, GemStone Systems, Inc. All Rights Reserved.
00010  * 1260 NW Waterhouse Ave Suite 200, Beaverton OR 97006.
00011  *=========================================================================
00012  */
00013 
00014 
00015 #include "gfcpp_globals.hpp"
00016 
00020 namespace gemfire {
00021 
00022 
00029 class CPPCACHE_EXPORT SharedBase {
00030 
00031 public:
00032 
00034   inline SharedBase() :
00035     m_refCount(0)
00036   {
00037   }
00038 
00040   void preserveSB() const;
00041 
00046   void releaseSB() const;
00047 
00049   inline int32_t refCount()
00050   {
00051     return m_refCount;
00052   }
00053 
00054 protected:
00055 
00056   inline SharedBase(bool noInit)
00057     {}
00058 
00059   virtual ~SharedBase()
00060     {}
00061 
00062 
00063 private:
00064 
00065   mutable volatile int32_t m_refCount;
00066 
00067   void operator = (const SharedBase& rhs);
00068 
00069 };
00070 
00076   class CPPCACHE_EXPORT NullSharedBase: public SharedBase
00077   {
00078   public:
00079     static const NullSharedBase* const s_instancePtr;
00080 
00081   private:
00082     NullSharedBase() { }
00083     // never defined
00084     NullSharedBase(const NullSharedBase&);
00085     NullSharedBase& operator =(const NullSharedBase&);
00086 
00087     friend class SharedBase; // just to get rid of warning with gcc3.x
00088   };
00089 
00090 }
00091 
00092 #define NULLPTR gemfire::NullSharedBase::s_instancePtr
00093 
00094 #endif //#define _GEMFIRE_SHAREDBASE_HPP_

GemFire C++ Cache API Documentation