#include <Rep.h>
Public Member Functions | |
Rep () | |
Rep (const Rep &) | |
Rep & | operator= (const Rep &) |
virtual | ~Rep () |
void | ref () const |
void | unref () const |
unsigned | refCount () const |
virtual const char * | repName () const |
virtual std::ostream & | dumpOn (std::ostream &str) const |
Static Public Member Functions | |
static void | ref (const Rep *obj_r) |
static void | unref (const Rep *obj_r) |
Protected Member Functions | |
virtual void | ref_to (unsigned) const |
virtual void | unref_to (unsigned) const |
Private Attributes | |
unsigned | _counter |
The initial reference count is zero. Calling ref(), the reference counter is increased. Calling unref(), the reference counter is decreased. If the reference count becomes zero, the object is deleted.
Any attempt to delete an object with a non zero reference count will throw an exeption.
Any attempt to unref() an object with a zero reference count will throw an exeption.
Stream output operator are provided for Rep and Rep*. Both use dumpOn(), which might be overloaded by derived classes.
Rep::Rep | ( | ) | [inline] |
Constructor. Initial reference count is zero.
Rep::Rep | ( | const Rep & | ) | [inline] |
CopyConstructor. Initial reference count is zero.
virtual Rep::~Rep | ( | ) | [inline, virtual] |
Destructor. Throws exception if reference count is not zero.
References _counter.
ostream & Rep::dumpOn | ( | std::ostream & | str | ) | const [virtual] |
Derived classes may overload this to realize std::ostream & operator<< for object and pointer classes.
Reimplemented in CountedRep.
References refCount(), and repName().
Referenced by operator<<().
static void Rep::ref | ( | const Rep * | obj_r | ) | [inline, static] |
Safe increment reference counter. Ignore NULL object pointer passed as argument.
References ref().
void Rep::ref | ( | ) | const [inline] |
Increment reference counter.
References _counter, and ref_to().
Referenced by BasicRepPtr::_assign(), RepPtrStore< _Tp, _Bt >::_assign(), ref(), and RepPtrStore< _Tp, _Bt >::tryAssign().
virtual void Rep::ref_to | ( | unsigned | ) | const [inline, protected, virtual] |
Trigger derived classes after refCount was increased.
Referenced by ref().
unsigned Rep::refCount | ( | ) | const [inline] |
Current reference counter value.
References _counter.
Referenced by CountedRep::dumpOn(), and dumpOn().
virtual const char* Rep::repName | ( | ) | const [inline, virtual] |
Objects name used in dumpOn().
Referenced by CountedRep::dumpOn(), and dumpOn().
static void Rep::unref | ( | const Rep * | obj_r | ) | [inline, static] |
Safe decrement reference counter. Ignore NULL object pointer passed as argument..
References unref().
void Rep::unref | ( | ) | const [inline] |
Decrement reference counter and delete the object if reference count got zero. Throws exception if reference count already is zero.
References _counter, and unref_to().
Referenced by BasicRepPtr::_assign(), RepPtrStore< _Tp, _Bt >::_assign(), RepPtrStore< _Tp, _Bt >::tryAssign(), and unref().
virtual void Rep::unref_to | ( | unsigned | ) | const [inline, protected, virtual] |
Trigger derived classes after refCount was decreased. No trigger is sent, if refCount got zero (i.e. the object is deleted).
Referenced by unref().
unsigned Rep::_counter [mutable, private] |
The reference counter.
Referenced by ref(), refCount(), unref(), and ~Rep().