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  )  [inline, private]

template<typename _Tp , typename _Bt >
_Bt * RepPtrStore< _Tp, _Bt >::base (  )  const [inline]

Explicit conversion to '_Bt *'

References RepPtrStore< _Tp, _Bt >::_obj.

Referenced by constPtr< _Tp, _Bt >::base().

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 [inline]

Explicit conversion to 'const Rep *'

References RepPtrStore< _Tp, _Bt >::_obj.

Referenced by constPtr< _Tp, _Bt >::refbase().

template<typename _Tp , typename _Bt>
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=().


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 a sunny day for yast2-core by doxygen 1.5.9