RefObjectBase

Files CCore/inc/RefObjectBase.h CCore/src/RefObjectBase.cpp

The class RefObjectBase appends the atomic reference counter and reference counting methods to the family of types. You can use this class with the class RefPtr to build a reference-counting smart pointer.


template <class ... TT>
class RefObjectBase : public NoCopyBase<MemBase,TT...>
 {
   Atomic refs;

  public:

   RefObjectBase() { refs=1; }

   virtual ~RefObjectBase() {}

   void incRef() { refs++; }

   bool decRef() { return (refs--)==1; }

   void destroy() { delete this; }
 };