Rep Class Reference

Base class for reference counted objects. More...

#include <Rep.h>

Inheritance diagram for Rep:
CountedRep Regex_t SymbolEntry Type YCode YSymbolEntry BlockType FlexType FunctionType ListType MapType NFlexType TupleType VariableType YBlock YConst YEBinary YEBracket YEBuiltin YECall YECompare YEIs YEList YELocale YEMap YEPropagate YEReference YEReturn YETerm YETriple YEUnary YEVariable YFunction YLocale YStatement

List of all members.

Public Member Functions

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

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  )  [inline]

CopyConstructor. Initial reference count is zero.

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

Destructor. Throws exception if reference count is not zero.

References _counter.


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.

References refCount(), and repName().

Referenced by operator<<().

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

Assignment. Reference count remains untouched.

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]
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().


Member Data Documentation

unsigned Rep::_counter [mutable, private]

The reference counter.

Referenced by ref(), refCount(), unref(), and ~Rep().


The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.6.3