yast2-core
|
Base class for reference counted objects. More...
#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 |
Base class for reference counted objects.
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.
|
inline |
Constructor. Initial reference count is zero.
|
inline |
CopyConstructor. Initial reference count is zero.
|
inlinevirtual |
Destructor. Throws exception if reference count is not zero.
|
virtual |
Derived classes may overload this to realize std::ostream & operator<< for object and pointer classes.
Reimplemented in CountedRep.
Referenced by operator<<().
Assignment. Reference count remains untouched.
Referenced by CountedRep::operator=().
|
inline |
Increment reference counter.
References ref_to().
Referenced by RepPtrStore< _Tp, _Bt >::_assign(), BasicRepPtr::_assign(), ref(), and RepPtrStore< _Tp, _Bt >::tryAssign().
|
inlinestatic |
Safe increment reference counter. Ignore NULL object pointer passed as argument.
References ref().
|
inlineprotectedvirtual |
Trigger derived classes after refCount was increased.
Referenced by ref().
|
inline |
Current reference counter value.
References _counter.
|
inlinevirtual |
Objects name used in dumpOn().
|
inline |
Decrement reference counter and delete the object if reference count got zero. Throws exception if reference count already is zero.
References unref_to().
Referenced by RepPtrStore< _Tp, _Bt >::_assign(), BasicRepPtr::_assign(), RepPtrStore< _Tp, _Bt >::tryAssign(), and unref().
|
inlinestatic |
Safe decrement reference counter. Ignore NULL object pointer passed as argument..
References unref().
|
inlineprotectedvirtual |
Trigger derived classes after refCount was decreased. No trigger is sent, if refCount got zero (i.e. the object is deleted).
Referenced by unref().
|
mutableprivate |
The reference counter.
Referenced by refCount().