yast2-core
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
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 YBreakpoint YConst YEBinary YEBracket YEBuiltin YECall YECompare YEIs YEList YELocale YEMap YEPropagate YEReference YEReturn YETerm YETriple YEUnary YEVariable YFunction YLocale YStatement

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 ( )
inlinevirtual

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.

Referenced by operator<<().

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

Assignment. Reference count remains untouched.

Referenced by CountedRep::operator=().

void Rep::ref ( ) const
inline
static void Rep::ref ( const Rep obj_r)
inlinestatic

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

References ref().

virtual void Rep::ref_to ( unsigned  ) const
inlineprotectedvirtual

Trigger derived classes after refCount was increased.

Referenced by ref().

unsigned Rep::refCount ( ) const
inline

Current reference counter value.

References _counter.

virtual const char* Rep::repName ( ) const
inlinevirtual

Objects name used in dumpOn().

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 RepPtrStore< _Tp, _Bt >::_assign(), BasicRepPtr::_assign(), RepPtrStore< _Tp, _Bt >::tryAssign(), and unref().

static void Rep::unref ( const Rep obj_r)
inlinestatic

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

References unref().

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

Member Data Documentation

unsigned Rep::_counter
mutableprivate

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.8.6