ContRap-Core
Public Member Functions | Static Public Member Functions | Static Protected Attributes

crp::SPtr< T > Class Template Reference

Class SPtr is a template typed reference counting pointer. More...

#include <pointer.h>

Inheritance diagram for crp::SPtr< T >:
crp::DPtr

Public Member Functions

 SPtr ()
 Empty constructor constructs an invalid pointer.
 SPtr (T *object, PointerMode mode=INSTANT)
 Pointer constructor from a pure object.
 SPtr (T *object, const DPtr &source, PointerMode mode=SOURCE)
 Pointer constructor from a pure object with reference data.
 SPtr (const DPtr &object, MetaInfo *meta_info)
 Creates a smart pointer from reference pointer.
 SPtr (const SPtr< T > &pointer)
 Copy constructor.
 ~SPtr ()
 Pointer destructor.
void operator= (const SPtr< T > &pointer)
 Assignment operator.
void operator= (T *pointer)
 Assignment operator from a pure pointer.
void copy_to (T *pointer) const
 Assignment operator using the assign function of the meta info.
void copy_to_create (T *pointer) const
 Assignment operator using the assign function of the meta info.
void copy_from (const SPtr< T > &pointer)
 Assignment operator using the assign function of the meta info.
bool operator== (const SPtr< T > &pointer) const
 Comparison operator.
 operator T * ()
 Returns the original object.
 operator const T * () const
 Returns the original object.
T & operator* ()
 Dereferences the pointer.
const T & operator* () const
 Dereferences the pointer.
T * operator-> ()
 Dereferences the pointer.
const T * operator-> () const
 Dereferences the pointer.
T * get_ptr ()
 Returns the pointer explicitly.
const T * get_ptr () const
 Returns the pointer explicitly.
void destroy ()
 Destroys the referenced object.

Static Public Member Functions

static void copy (const T *from, T *to)
 Static copy method for the given type.
static MetaInfoget_static_meta_info ()
 Returns the static meta information.

Static Protected Attributes

static MetaInfostatic_meta_info = 0
 Static meta info object.

Detailed Description

template<class T>
class crp::SPtr< T >

Class SPtr is a template typed reference counting pointer.

By overloading the copy constructor it is possible to assign smart pointers thus counting the number of references to the wrapped object. As the reference number goes down to zero the wrapped object is deleted.


Constructor & Destructor Documentation

template<class T>
crp::SPtr< T >::SPtr ( ) [inline]

Empty constructor constructs an invalid pointer.

template<class T>
crp::SPtr< T >::SPtr ( T *  object,
PointerMode  mode = INSTANT 
) [inline]

Pointer constructor from a pure object.

The ContRap policy forbids to use this constructor in all cases except immediately after you have created a new instance of the wrapped object.

Parameters:
objectPointer to the object
modeDestruction mode
template<class T>
crp::SPtr< T >::SPtr ( T *  object,
const DPtr source,
PointerMode  mode = SOURCE 
) [inline]

Pointer constructor from a pure object with reference data.

The reference object will not be deleted until the last copy of this pointer is deleted. The deletion mode of this pointer is per default PERSISTENT.

The ContRap policy forbids to use this constructor in all cases except immediately after you have created a new instance of the wrapped object.

Parameters:
objectPointer to the object
sourceSource object of the data
modeDestruction mode of the pointer
template<class T>
crp::SPtr< T >::SPtr ( const DPtr object,
MetaInfo meta_info 
) [inline]

Creates a smart pointer from reference pointer.

Parameters:
objectReference object
meta_infoMeta info of the object
template<class T>
crp::SPtr< T >::SPtr ( const SPtr< T > &  pointer) [inline]

Copy constructor.

Parameters:
pointerOther reference pointer
template<class T>
crp::SPtr< T >::~SPtr ( ) [inline]

Pointer destructor.


Member Function Documentation

template<class T>
static void crp::SPtr< T >::copy ( const T *  from,
T *  to 
) [inline, static]

Static copy method for the given type.

Parameters:
fromSource object
toTarget object
template<class T>
void crp::SPtr< T >::copy_from ( const SPtr< T > &  pointer) [inline]

Assignment operator using the assign function of the meta info.

Parameters:
pointerOther reference
template<class T>
void crp::SPtr< T >::copy_to ( T *  pointer) const [inline]

Assignment operator using the assign function of the meta info.

Parameters:
pointerOther reference
template<class T>
void crp::SPtr< T >::copy_to_create ( T *  pointer) const [inline]

Assignment operator using the assign function of the meta info.

Parameters:
pointerOther reference
template<class T>
void crp::SPtr< T >::destroy ( ) [inline]

Destroys the referenced object.

Reimplemented from crp::DPtr.

template<class T>
T* crp::SPtr< T >::get_ptr ( ) [inline]

Returns the pointer explicitly.

Returns:
Pure object pointer

Reimplemented from crp::DPtr.

template<class T>
const T* crp::SPtr< T >::get_ptr ( ) const [inline]

Returns the pointer explicitly.

Returns:
Pure object pointer
template<class T>
static MetaInfo* crp::SPtr< T >::get_static_meta_info ( ) [inline, static]

Returns the static meta information.

Returns:
Static meta information
template<class T>
crp::SPtr< T >::operator const T * ( ) const [inline]

Returns the original object.

Returns:
Pointer to the original object
template<class T>
crp::SPtr< T >::operator T * ( ) [inline]

Returns the original object.

Returns:
Pointer to the original object
template<class T>
T& crp::SPtr< T >::operator* ( ) [inline]

Dereferences the pointer.

Returns:
Pure object pointer
template<class T>
const T& crp::SPtr< T >::operator* ( ) const [inline]

Dereferences the pointer.

Returns:
Pure object pointer
template<class T>
T* crp::SPtr< T >::operator-> ( ) [inline]

Dereferences the pointer.

Returns:
Pure object pointer
template<class T>
const T* crp::SPtr< T >::operator-> ( ) const [inline]

Dereferences the pointer.

Returns:
Pure object pointer
template<class T>
void crp::SPtr< T >::operator= ( T *  pointer) [inline]

Assignment operator from a pure pointer.

Parameters:
pointerObject to assign
template<class T>
void crp::SPtr< T >::operator= ( const SPtr< T > &  pointer) [inline]

Assignment operator.

Parameters:
pointerOther reference pointer
template<class T>
bool crp::SPtr< T >::operator== ( const SPtr< T > &  pointer) const [inline]

Comparison operator.

Parameters:
pointerOther reference pointer

Field Documentation

template<class T>
MetaInfo * crp::SPtr< T >::static_meta_info = 0 [static, protected]

Static meta info object.

Static meta information for each smart pointer class.


The documentation for this class was generated from the following file: