In file refcount/refcount.hh:

template <class T> class dynamic_ref_counter

dynamic reference counter.

Inheritance:


Public Fields

typedef T class_type
Parent class type
typedef static_ref_counter <T> counter_type
Static reference counter

Public Methods

int getCount () const
Get the reference count
T* getParent () const
Get the parent class
void setParent (T* parent, bool array = false)
Set the parent class
explicit dynamic_ref_counter (T* parent = 0, bool array = false)
Constructor
~dynamic_ref_counter ()
Destructor
dynamic_ref_counter (const dynamic_ref_counter& dref)
Copy constructor
dynamic_ref_counter (counter_type* sref)
Copy constructor (from a static reference counter)
dynamic_ref_counter& operator= (const dynamic_ref_counter& dref)
Assignment operator
dynamic_ref_counter& operator= (counter_type* sref)
Assignment operator (from a static reference counter)
T& operator* () const
dereference operator (returns parent)
T* operator-> () const
member access operator (returns parent)

Documentation

A templated reference counter. This counter maintains a pointer to a static reference counter. The counter value is initialized with one and is increased everytime the counter is copied and decreased everytime the counter is destroyed.

Example:

    // class which manages a shared floating point array
    class container {
       float* fData; // must be before reference counter!
       dynamic_ref_counter<float> fRef;
    public:
       container (int size)
        : fData (new float[size]), fRef (fData, true) {}
       ...
    };
    // This is all what is needed to implement reference counting on
    // the data array. The user does not have to implement a 
    // destructor, a copy costructor nor assignment operator.
    // Because of the reference counter, the above example class 
    // implements a "shared" copy paradigm and destroyes the 
    // data automatically when no longer needed.
    

typedef T class_type
Parent class type

typedef static_ref_counter <T> counter_type
Static reference counter

int getCount() const
Get the reference count

T* getParent() const
Get the parent class

void setParent(T* parent, bool array = false)
Set the parent class

explicit dynamic_ref_counter(T* parent = 0, bool array = false)
Constructor

~dynamic_ref_counter()
Destructor

dynamic_ref_counter(const dynamic_ref_counter& dref)
Copy constructor

dynamic_ref_counter(counter_type* sref)
Copy constructor (from a static reference counter)

dynamic_ref_counter& operator= (const dynamic_ref_counter& dref)
Assignment operator

dynamic_ref_counter& operator= (counter_type* sref)
Assignment operator (from a static reference counter)

T& operator*() const
dereference operator (returns parent)

T* operator->() const
member access operator (returns parent)


This class has no child classes.

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++