yast2-core
|
A '_Tp*' with reference counting on construction and assign. More...
#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 |
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>
|
inline |
DefaultConstructor. NULL
|
inline |
Constructor. Uses _assign.
|
inline |
CopyConstructor. Uses _assign.
|
inline |
Destructor. Uses _assign.
|
private |
Assign a new value to _obj. Adjusts the objects reference counter according to the old and new pointer value.
References Rep::ref(), and Rep::unref().
Referenced by RepPtrStore< const _Tp, const _Bt >::operator=(), RepPtrStore< const _Tp, const _Bt >::RepPtrStore(), and RepPtrStore< const _Tp, const _Bt >::~RepPtrStore().
_Bt * RepPtrStore< _Tp, _Bt >::base | ( | ) | const |
Explicit conversion to '_Bt *'
Referenced by constPtr< _Tp, _Bt >::base().
|
inline |
Conversion to '_Tp *'
|
inline |
Assign. Uses _assign.
|
inline |
Assign. Uses _assign.
const Rep * RepPtrStore< _Tp, _Bt >::refbase | ( | ) | const |
Explicit conversion to 'const Rep *'
Referenced by constPtr< _Tp, _Bt >::refbase().
void RepPtrStore< _Tp, _Bt >::tryAssign | ( | _Bt * | ptr | ) |
Assign the result of dynamic_cast '_Bt *' to '_Tp *'. Uses _assign.
References Rep::ref(), and Rep::unref().
Referenced by constPtr< _Tp, _Bt >::constPtr(), and constPtr< _Tp, _Bt >::operator=().
|
private |