Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Rep Class Reference

Base class for reference counted objects. More...

#include <Rep.h>

Inheritance diagram for Rep:

CountedRep TagCacheRetrieval List of all members.

Public Member Functions

 Rep ()
 Rep (const Rep &rhs)
Repoperator= (const Rep &rhs)
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

void ref (const Rep *obj_r)
void unref (const Rep *obj_r)

Protected Member Functions

virtual void ref_to (unsigned rep_cnt_r) const
virtual void unref_to (unsigned rep_cnt_r) const

Private Attributes

unsigned _counter

Detailed Description

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.


Constructor & Destructor Documentation

Rep::Rep  )  [inline]
 

Constructor. Initial reference count is zero.

Rep::Rep const Rep rhs  )  [inline]
 

CopyConstructor. Initial reference count is zero.

virtual Rep::~Rep  )  [inline, virtual]
 

Destructor. Throws exception if reference count is not zero.


Member Function Documentation

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.

Rep& Rep::operator= const Rep rhs  )  [inline]
 

Assignment. Reference count remains untouched.

void Rep::ref const Rep obj_r  )  [inline, static]
 

Safe increment reference counter. Ignore NULL object pointer passed as argument.

void Rep::ref  )  const [inline]
 

Increment reference counter.

virtual void Rep::ref_to unsigned  rep_cnt_r  )  const [inline, protected, virtual]
 

Trigger derived classes after refCount was increased.

unsigned Rep::refCount  )  const [inline]
 

Current reference counter value.

virtual const char* Rep::repName  )  const [inline, virtual]
 

Objects name used in dumpOn().

void Rep::unref const Rep obj_r  )  [inline, static]
 

Safe decrement reference counter. Ignore NULL object pointer passed as argument..

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.

virtual void Rep::unref_to unsigned  rep_cnt_r  )  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).


Member Data Documentation

unsigned Rep::_counter [mutable, private]
 

The reference counter.


The documentation for this class was generated from the following files:
Generated on Thu Feb 23 23:56:11 2006 for liby2util by doxygen 1.3.6