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

RepPtrStore< _Tp, _Bt > Class Template Reference

A '_Tp*' with reference counting on construction and assign. More...

#include <Rep.h>

List of all members.

Public Member Functions

 RepPtrStore ()
 RepPtrStore (_Tp *ptr)
 RepPtrStore (const RepPtrStore &rhs)
RepPtrStoreoperator= (_Tp *ptr)
RepPtrStoreoperator= (const RepPtrStore &rhs)
 ~RepPtrStore ()
 operator _Tp * () const
void tryAssign (_Bt *ptr)
_Bt * base () const
const Reprefbase () const

Private Member Functions

void _assign (_Tp *new_r)

Private Attributes

_Tp * _obj


Detailed Description

template<typename _Tp, typename _Bt = _Tp>
class RepPtrStore< _Tp, _Bt >

A '_Tp*' with reference counting on construction and assign.

Class _Tp must inherit class Rep. tryAssign() supports assignment from '_Bt *' via dynamic_cast. Thus _Bt must either be _Tp, or a baseclass of _Tp.

The counted pointer template classes Ptr and constPtr use RepPtrStore to store the 'object *'. Intentionally all methods which require more than a forward declaration of classes _Tp and _Bt are defined within RepPtrStore and not inlined.

To use an ordinary _Tp*, a forward declaration class _Tp; is sufficient, unless you actually access the '_Tp' object. Using a counted pointer, you'll have to pervent the implicit generation of RepPtrStore<_Tp> instances too. Otherwise the definition of class _Tp had to be provided.

#include <y2util/Rep.h> // template definition class Foo; // forward declare class Foo extern template class RepPtrStore<Foo>; // pervent implicit instanciation of RepPtrStore<Foo>

Then within some translation unit you'll have to explicitly instantiate RepPtrStore<Foo>.

#include <y2util/Rep.h> // template definition #include "Foo.h" // definition of class Foo template class RepPtrStore<Foo>; // explicit instantiation of RepPtrStore<Foo>


Constructor & Destructor Documentation

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore< _Tp, _Bt >::RepPtrStore  )  [inline]
 

DefaultConstructor. NULL

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore< _Tp, _Bt >::RepPtrStore _Tp *  ptr  )  [inline]
 

Constructor. Uses _assign.

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore< _Tp, _Bt >::RepPtrStore const RepPtrStore< _Tp, _Bt > &  rhs  )  [inline]
 

CopyConstructor. Uses _assign.

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore< _Tp, _Bt >::~RepPtrStore  )  [inline]
 

Destructor. Uses _assign.


Member Function Documentation

template<typename _Tp, typename _Bt>
void RepPtrStore< _Tp, _Bt >::_assign _Tp *  new_r  )  [private]
 

Assign a new value to _obj. Adjusts the objects reference counter according to the old and new pointer value.

template<typename _Tp, typename _Bt>
_Bt * RepPtrStore< _Tp, _Bt >::base  )  const
 

Explicit conversion to '_Bt *'

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore< _Tp, _Bt >::operator _Tp *  )  const [inline]
 

Conversion to '_Tp *'

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore& RepPtrStore< _Tp, _Bt >::operator= const RepPtrStore< _Tp, _Bt > &  rhs  )  [inline]
 

Assign. Uses _assign.

template<typename _Tp, typename _Bt = _Tp>
RepPtrStore& RepPtrStore< _Tp, _Bt >::operator= _Tp *  ptr  )  [inline]
 

Assign. Uses _assign.

template<typename _Tp, typename _Bt>
const Rep * RepPtrStore< _Tp, _Bt >::refbase  )  const
 

Explicit conversion to 'const Rep *'

template<typename _Tp, typename _Bt>
void RepPtrStore< _Tp, _Bt >::tryAssign _Bt *  ptr  ) 
 

Assign the result of dynamic_cast '_Bt *' to '_Tp *'. Uses _assign.


Member Data Documentation

template<typename _Tp, typename _Bt = _Tp>
_Tp* RepPtrStore< _Tp, _Bt >::_obj [private]
 

The pointer.


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