ARB
Public Member Functions | List of all members
SmartPtr< T, C > Class Template Reference

Generic smart pointer. More...

#include <smartptr.h>

Inheritance diagram for SmartPtr< T, C >:
Inheritance graph
[legend]

Public Member Functions

 SmartPtr ()
 build Smart-NULp-Ptr More...
 
 SmartPtr (T *p)
 
 ~SmartPtr ()
 
 SmartPtr (const SmartPtr< T, C > &other)
 
SmartPtr< T, C > & operator= (const SmartPtr< T, C > &other)
 
const Toperator-> () const
 
Toperator-> ()
 
const Toperator* () const
 
Toperator* ()
 
bool isSet () const
 test if SmartPtr is not NULp More...
 
bool isNull () const
 test if SmartPtr is NULp More...
 
void setNull ()
 set SmartPtr to NULp More...
 
void assign (T *p)
 set SmartPtr to new content or NULp More...
 
const Tcontent () const
 convert SmartPtr to plain old pointer (also works if isNull()) More...
 
SmartPtr< T, Cdeep_copy () const
 
bool sameObject (const SmartPtr< T, C > &other) const
 
unsigned references () const
 

Detailed Description

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
class SmartPtr< T, C >

Generic smart pointer.

Definition at line 149 of file smartptr.h.

Constructor & Destructor Documentation

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr< T, C >::SmartPtr ( )
inline

build Smart-NULp-Ptr

Definition at line 205 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr< T, C >::SmartPtr ( T p)
inline

build normal SmartPtr

by passing an object to a SmartPtr you loose the responsibility over the object to the SmartPtr. So you NEVER should free such an object manually.

Parameters
pPointer to any dynamically allocated object

Definition at line 215 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr< T, C >::~SmartPtr ( )
inline

destroy SmartPtr

object will not be destroyed as long as any other SmartPtr points to it

Definition at line 224 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr< T, C >::SmartPtr ( const SmartPtr< T, C > &  other)
inline

Definition at line 226 of file smartptr.h.

Member Function Documentation

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr<T, C>& SmartPtr< T, C >::operator= ( const SmartPtr< T, C > &  other)
inline

Definition at line 231 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
const T* SmartPtr< T, C >::operator-> ( ) const
inline

Definition at line 238 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
T* SmartPtr< T, C >::operator-> ( )
inline

Definition at line 239 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
const T& SmartPtr< T, C >::operator* ( ) const
inline

Definition at line 241 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
T& SmartPtr< T, C >::operator* ( )
inline

Definition at line 242 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
bool SmartPtr< T, C >::isSet ( ) const
inline
template<class T, class C = Counted<T, auto_delete_ptr<T> >>
bool SmartPtr< T, C >::isNull ( ) const
inline
template<class T, class C = Counted<T, auto_delete_ptr<T> >>
void SmartPtr< T, C >::setNull ( )
inline
template<class T, class C = Counted<T, auto_delete_ptr<T> >>
void SmartPtr< T, C >::assign ( T p)
inline

set SmartPtr to new content or NULp

Definition at line 254 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
const T* SmartPtr< T, C >::content ( ) const
inline

convert SmartPtr to plain old pointer (also works if isNull())

Definition at line 263 of file smartptr.h.

Referenced by ED4_get_aligner_data_access(), and SetVariables::get().

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
SmartPtr<T, C> SmartPtr< T, C >::deep_copy ( ) const
inline

create a deep copy of the object pointed to by the smart pointer.

Afterwards there exist two equal copies of the object.

Returns
SmartPtr to the new copy.

Definition at line 267 of file smartptr.h.

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
bool SmartPtr< T, C >::sameObject ( const SmartPtr< T, C > &  other) const
inline

test if two SmartPtrs point to the same object

(this is used for operators == and !=).

if you like to compare the objects themselves use (*smart_ptr1 == *smart_ptr2)

Returns
true if the SmartPtrs point to the same object

Definition at line 277 of file smartptr.h.

Referenced by operator!=(), and operator==().

template<class T, class C = Counted<T, auto_delete_ptr<T> >>
unsigned SmartPtr< T, C >::references ( ) const
inline

Definition at line 292 of file smartptr.h.


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