build-artifacts/win/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  * Copyright (c) 2004-2014 Pivotal Software, Inc. All Rights Reserved.
00010  * This product is protected by U.S. and international copyright
00011  * and intellectual property laws. Pivotal products are covered by
00012  * more patents listed at http://www.pivotal.io/patents.
00013  *=========================================================================
00014  */
00015 
00016 
00017 #include "gfcpp_globals.hpp"
00018 
00022 namespace gemfire {
00023 
00024 
00031 class CPPCACHE_EXPORT SharedBase {
00032 
00033 public:
00034 
00036   inline SharedBase() :
00037     m_refCount(0)
00038   {
00039   }
00040 
00042   void preserveSB() const;
00043 
00048   void releaseSB() const;
00049 
00051   inline int32_t refCount()
00052   {
00053     return m_refCount;
00054   }
00055 
00056 protected:
00057 
00058   inline SharedBase(bool noInit)
00059     {}
00060 
00061   virtual ~SharedBase()
00062     {}
00063 
00064 
00065 private:
00066 
00067   mutable volatile int32_t m_refCount;
00068 
00069   void operator = (const SharedBase& rhs);
00070 
00071 };
00072 
00078   class CPPCACHE_EXPORT NullSharedBase: public SharedBase
00079   {
00080   public:
00081     static const NullSharedBase* const s_instancePtr;
00082 
00083   private:
00084     NullSharedBase() { }
00085     // never defined
00086     NullSharedBase(const NullSharedBase&);
00087     NullSharedBase& operator =(const NullSharedBase&);
00088 
00089     friend class SharedBase; // just to get rid of warning with gcc3.x
00090   };
00091 
00092 }
00093 
00094 #define NULLPTR gemfire::NullSharedBase::s_instancePtr
00095 
00096 #endif //#define _GEMFIRE_SHAREDBASE_HPP_

GemFire C++ Cache API Documentation