RepPtrStore< _Tp, _Bt > Class Template Reference
A '_Tp*' with reference counting on construction and assign.
More...
#include <Rep.h>
List of all members.
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
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] |
|
template<typename _Tp, typename _Bt = _Tp> |
RepPtrStore& RepPtrStore< _Tp, _Bt >::operator= |
( |
_Tp * |
ptr |
) |
[inline] |
|
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 documentation for this class was generated from the following file:
Generated on Thu Feb 23 23:56:11 2006 for liby2util by
1.3.6