#include <Rep.h>
Public Member Functions | |
RepPtrStore () | |
RepPtrStore (_Tp *ptr) | |
RepPtrStore (const RepPtrStore &rhs) | |
RepPtrStore & | operator= (_Tp *ptr) |
RepPtrStore & | operator= (const RepPtrStore &rhs) |
~RepPtrStore () | |
operator _Tp * () const | |
void | tryAssign (_Bt *ptr) |
_Bt * | base () const |
const Rep * | refbase () const |
Private Member Functions | |
void | _assign (_Tp *new_r) |
Private Attributes | |
_Tp * | _obj |
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>
RepPtrStore< _Tp, _Bt >::RepPtrStore | ( | ) | [inline] |
DefaultConstructor. NULL
RepPtrStore< _Tp, _Bt >::RepPtrStore | ( | _Tp * | ptr | ) | [inline] |
Constructor. Uses _assign.
RepPtrStore< _Tp, _Bt >::RepPtrStore | ( | const RepPtrStore< _Tp, _Bt > & | rhs | ) | [inline] |
CopyConstructor. Uses _assign.
RepPtrStore< _Tp, _Bt >::~RepPtrStore | ( | ) | [inline] |
Destructor. Uses _assign.
void RepPtrStore< _Tp, _Bt >::_assign | ( | _Tp * | new_r | ) | [inline, private] |
Assign a new value to _obj. Adjusts the objects reference counter according to the old and new pointer value.
References RepPtrStore< _Tp, _Bt >::_obj, Rep::ref(), and Rep::unref().
Referenced by RepPtrStore< const _Tp, const _Bt >::operator=(), RepPtrStore< const _Tp, const _Bt >::RepPtrStore(), RepPtrStore< _Tp, _Bt >::tryAssign(), and RepPtrStore< const _Tp, const _Bt >::~RepPtrStore().
_Bt * RepPtrStore< _Tp, _Bt >::base | ( | ) | const [inline] |
Explicit conversion to '_Bt *'
References RepPtrStore< _Tp, _Bt >::_obj.
Referenced by constPtr< _Tp, _Bt >::base().
RepPtrStore< _Tp, _Bt >::operator _Tp * | ( | ) | const [inline] |
Conversion to '_Tp *'
RepPtrStore& RepPtrStore< _Tp, _Bt >::operator= | ( | const RepPtrStore< _Tp, _Bt > & | rhs | ) | [inline] |
Assign. Uses _assign.
RepPtrStore& RepPtrStore< _Tp, _Bt >::operator= | ( | _Tp * | ptr | ) | [inline] |
Assign. Uses _assign.
const Rep * RepPtrStore< _Tp, _Bt >::refbase | ( | ) | const [inline] |
Explicit conversion to 'const Rep *'
References RepPtrStore< _Tp, _Bt >::_obj.
Referenced by constPtr< _Tp, _Bt >::refbase().
void RepPtrStore< _Tp, _Bt >::tryAssign | ( | _Bt * | ptr | ) | [inline] |
Assign the result of dynamic_cast '_Bt *' to '_Tp *'. Uses _assign.
References RepPtrStore< _Tp, _Bt >::_assign(), RepPtrStore< _Tp, _Bt >::_obj, Rep::ref(), and Rep::unref().
Referenced by constPtr< _Tp, _Bt >::constPtr(), and constPtr< _Tp, _Bt >::operator=().
_Tp* RepPtrStore< _Tp, _Bt >::_obj [private] |
The pointer.
Referenced by RepPtrStore< _Tp, _Bt >::_assign(), RepPtrStore< _Tp, _Bt >::base(), RepPtrStore< const _Tp, const _Bt >::operator const _Tp *(), RepPtrStore< const _Tp, const _Bt >::operator=(), RepPtrStore< _Tp, _Bt >::refbase(), RepPtrStore< const _Tp, const _Bt >::RepPtrStore(), and RepPtrStore< _Tp, _Bt >::tryAssign().