Handle< T > Class Template Reference

Handle class template - a simplified version of boost::intrusive_ptr. More...

#include <Handle.h>

List of all members.

Public Member Functions

 Handle ()
 Handle (T *ptr)
 Handle (const Handle &rhs)
 ~Handle ()
Handleoperator= (const Handle &rhs)
T * operator-> () const
T & operator* () const
void release ()
bool operator== (const Handle &rhs)
bool operator!= (const Handle &rhs)

Private Member Functions

void init ()

Private Attributes

T * p

Detailed Description

template<typename T>
class Handle< T >

Handle class template - a simplified version of boost::intrusive_ptr.

_____________________________________________________________________________

It's a smart pointer for objects with "built-in" reference count. Such implemetation makes the smallest possible smart pointer - its size is equivalent to just a single raw pointer.

_____________________________________________________________________________

Definition at line 18 of file CandFitTrackSA/HEAD/Handle.h.


Constructor & Destructor Documentation

template<typename T >
Handle< T >::Handle (  )  [inline]

default ctor

Definition at line 79 of file CandFitTrackSA/HEAD/Handle.h.

00079                   : p(0)
00080 {}

template<typename T >
Handle< T >::Handle ( T *  realPtr  )  [inline]

ctor from a raw pointer

Definition at line 86 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::init().

00086                             : p(realPtr)
00087 {
00088     init();
00089 }

template<typename T >
Handle< T >::Handle ( const Handle< T > &  rhs  )  [inline]

copy ctor

Definition at line 95 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::init().

00095                                    : p(rhs.p)
00096 {
00097     init();
00098 }

template<typename T >
Handle< T >::~Handle (  )  [inline]

dtor

Definition at line 136 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00137 {
00138     if (p) p->release();
00139 }


Member Function Documentation

template<typename T >
void Handle< T >::init (  )  [inline, private]

init

Definition at line 123 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

Referenced by Handle< T >::Handle(), and Handle< T >::operator=().

00124 {
00125     if (p == 0) {
00126         return;
00127     }
00128 
00129     p->add_ref();
00130 }

template<typename T >
bool Handle< T >::operator!= ( const Handle< T > &  rhs  )  [inline]

!= operator - compares raw pointers

Definition at line 188 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00189 {
00190     if (p != rhs.p)
00191        return true;
00192 
00193     return false;
00194 }

template<typename T >
T & Handle< T >::operator* (  )  const [inline]

dereference operator

Definition at line 156 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00157 { 
00158     return *p; 
00159 }

template<typename T >
T * Handle< T >::operator-> (  )  const [inline]

operator-> allows usage with pointer semantics

Definition at line 146 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00147 { 
00148     return p; 
00149 }

template<typename T >
Handle< T > & Handle< T >::operator= ( const Handle< T > &  rhs  )  [inline]

assignment operator

Definition at line 105 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::init(), and Handle< T >::p.

00106 {
00107     if (p != rhs.p) {
00108         if (p) {
00109             p->release();
00110         }
00111 
00112         p = rhs.p;
00113         init();
00114     }
00115     return *this;
00116 }

template<typename T >
bool Handle< T >::operator== ( const Handle< T > &  rhs  )  [inline]

== operator - compares raw pointers

Definition at line 176 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00177 {
00178     if (p == rhs.p)
00179        return true;
00180 
00181     return false;
00182 }

template<typename T >
void Handle< T >::release (  )  [inline]

release - set pointer to 0

Definition at line 165 of file CandFitTrackSA/HEAD/Handle.h.

References Handle< T >::p.

00166 {
00167     if (p) p->release();
00168     p = 0;
00169 }


Member Data Documentation

template<typename T>
T* Handle< T >::p [private]

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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1