Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Refstorage_ Class Template Reference

Class Refstorage_: implements a handler and a data container that support copy-on-write and reference counting. More...

#include <Refstorage.hh>

Collaboration diagram for RazorBack::Refstorage_:

Collaboration graph
[legend]
List of all members.

Protected Methods

 Refstorage_ ()
 default ctor, inits to empty.

 Refstorage_ (const T_ *Dp)
 Inits with a freshly created data object pointed to by Dp. More...

 Refstorage_ (const Refstorage_< T_ > &Rf)
 copy ctor, implements shallow copy.

virtual ~Refstorage_ ()
 destructor.

Refstorage_<T_>& operator= (const Refstorage_< T_ > &Rhs)
 assignment.

void unlink_old ()
 unlink_old(): unlinks old storage (decr Refcount and delete if there are no more links).

void clone ()
 clone(): clones Storptr if it is referenced by at least another object.

void replace_storage (const T_ *Dp)
 replace_storage(Dp): replaces old storage with new storage so that the data Dp will be stored. More...

bool empty () const
 Returns true if there is no stored data.

const T_& data () const
 data(): (Const) access to the stored data itself. More...

T_& data ()
const T_* ptr () const
 ptr(): Returns a (const) pointer to the stored data. More...

T_* ptr ()

Private Attributes

Storage_Storptr

Detailed Description

template<class T_> class RazorBack::Refstorage_

Class Refstorage_: implements a handler and a data container that support copy-on-write and reference counting.

There are no public methods: this class is intended as a (protected) base class for other classes that have lots of data. The data objects should be contained in a separate class that will be substituted as T_.

Definition at line 32 of file Refstorage.hh.


Constructor & Destructor Documentation

template<class T_>
RazorBack::Refstorage_<T_>::Refstorage_<T_> ( ) [inline, protected]
 

default ctor, inits to empty.

Definition at line 78 of file Refstorage.hh.

template<class T_>
RazorBack::Refstorage_<T_>::Refstorage_<T_> ( const T_ * Dp ) [inline, explicit, protected]
 

Inits with a freshly created data object pointed to by Dp.

Since ownership is taken by Refstorage_, de-allocation will be performed by it. For this reason, the only wise invocation of this ctor is Refstorage_<T_>(new T_(params...))

Definition at line 87 of file Refstorage.hh.

template<class T_>
RazorBack::Refstorage_<T_>::Refstorage_<T_> ( const Refstorage_< T_ > & Rf ) [inline, protected]
 

copy ctor, implements shallow copy.

Definition at line 94 of file Refstorage.hh.

template<class T_>
RazorBack::Refstorage_<T_>::~Refstorage_<T_> ( ) [inline, protected, virtual]
 

destructor.

Definition at line 101 of file Refstorage.hh.


Member Function Documentation

template<class T_>
Refstorage_< T_ > & RazorBack::Refstorage_<T_>::operator= ( const Refstorage_< T_ > & Rhs ) [inline, protected]
 

assignment.

Definition at line 107 of file Refstorage.hh.

template<class T_>
void RazorBack::Refstorage_<T_>::unlink_old ( ) [inline, protected]
 

unlink_old(): unlinks old storage (decr Refcount and delete if there are no more links).

Definition at line 121 of file Refstorage.hh.

Referenced by clone(), operator=(), replace_storage(), and ~Refstorage_().

template<class T_>
void RazorBack::Refstorage_<T_>::clone ( ) [inline, protected]
 

clone(): clones Storptr if it is referenced by at least another object.

Definition at line 128 of file Refstorage.hh.

template<class T_>
void RazorBack::Refstorage_<T_>::replace_storage ( const T_ * Dp ) [inline, protected]
 

replace_storage(Dp): replaces old storage with new storage so that the data Dp will be stored.

The same rule applies for Dp as for the ctor with the same arg: Dp must point to a freshly created, dynamically allocated object of type T_.

Definition at line 145 of file Refstorage.hh.

template<class T_>
bool RazorBack::Refstorage_<T_>::empty ( ) const [inline, protected]
 

Returns true if there is no stored data.

Definition at line 153 of file Refstorage.hh.

Referenced by data(), and ptr().

template<class T_>
const T_ & RazorBack::Refstorage_<T_>::data ( ) const [inline, protected]
 

data(): (Const) access to the stored data itself.

Throws Emptyexc if the calling object was empty.

Definition at line 159 of file Refstorage.hh.

template<class T_>
T_ & RazorBack::Refstorage_<T_>::data ( ) [inline, protected]
 

Definition at line 165 of file Refstorage.hh.

template<class T_>
const T_ * RazorBack::Refstorage_<T_>::ptr ( ) const [inline, protected]
 

ptr(): Returns a (const) pointer to the stored data.

Returns NULL if the calling object was empty.

Definition at line 176 of file Refstorage.hh.

template<class T_>
T_ * RazorBack::Refstorage_<T_>::ptr ( ) [inline, protected]
 

Definition at line 177 of file Refstorage.hh.


Member Data Documentation

template<class T_>
Storage_* RazorBack::Refstorage_<T_>::Storptr [private]
 

Definition at line 72 of file Refstorage.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:41 2002 for The Razorback C++ Library: Miscellaneous by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001