Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Member Functions | Friends | Related Functions | List of all members
BIAS::SharedPtr< T > Class Template Reference

pointer with reference count and automatic deletion More...

#include <Base/Common/SharedPtr.hh>

+ Inheritance diagram for BIAS::SharedPtr< T >:

Classes

class  Tester
 

Public Member Functions

template<class U >
SharedPtr< T > ConstCast (const SharedPtr< U > &rs)
 eqivalent to *this = const_cast<SharedPtr<T> >(rs) More...
 
template<class U >
SharedPtr< T > DynamicCast (const SharedPtr< U > &rs)
 eqivalent to *this = dynamic_cast<SharedPtr<T> >(rs) More...
 
 operator Tester * () const
 Enable the expression "if (ptr)", while at the same time preventing "delete ptr" from compilling. More...
 
bool operator! () const
 enable the expression "if (!ptr)" More...
 
template<class U >
bool operator!= (const SharedPtr< U > &rs) const
 
T & operator* () const
 
T * operator-> () const
 
template<class U >
bool operator< (const SharedPtr< U > &rs) const
 ordering More...
 
template<class U >
bool operator<= (const SharedPtr< U > &rs) const
 
SharedPtr< T > & operator= (const SharedPtr< T > &sp)
 
template<class U >
bool operator== (const SharedPtr< U > &rs) const
 comparisons More...
 
template<class U >
bool operator> (const SharedPtr< U > &rs) const
 
template<class U >
bool operator>= (const SharedPtr< U > &rs) const
 
 SharedPtr ()
 
template<class U >
 SharedPtr (const SharedPtr< U > &pt)
 needed to enable assignement of SharedPtr<T> to SharedPtr<const T> More...
 
 SharedPtr (const SharedPtr< T > &pt)
 
 SharedPtr (T *pt)
 
virtual ~SharedPtr ()
 

Friends

T * Get (SharedPtr< T > &t)
 access functions More...
 
T *const Get (const SharedPtr< T > &t)
 
std::ostream & operator<< (std::ostream &os, const SharedPtr< T > &t)
 stream operator More...
 
unsigned RefCount (const SharedPtr< T > &t)
 
template<class U >
class SharedPtr
 

Related Functions

(Note that these are not member functions.)

template<class T , class U >
SharedPtr< T > ConstCast (const SharedPtr< U > &src)
 DynamicCast function. More...
 
template<class T , class U >
SharedPtr< T > DynamicCast (const SharedPtr< U > &src)
 DynamicCast function. More...
 
template<class T >
T * Get (SharedPtr< T > &t)
 access function to the raw pointer More...
 
template<class T >
T *const Get (const SharedPtr< T > &t)
 access function to the raw pointer More...
 
template<class T >
unsigned RefCount (const SharedPtr< T > &t)
 access function to the reference count More...
 

Detailed Description

template<class T>
class BIAS::SharedPtr< T >

pointer with reference count and automatic deletion

This class is tested see Base/Common/Tests/TestSharedPtr.cpp

!this class is not thread safe!

Author
woelk 09/2007 (c) www.vision-n.de
Examples:
ExampleCalibratedPyramid.cpp, ExampleProgressSemaphore.cpp, ExampleSharedPtr.cpp, and TestCalibratedPyramid.cpp.

Definition at line 50 of file SharedPtr.hh.

Constructor & Destructor Documentation

template<class T >
BIAS::SharedPtr< T >::SharedPtr ( )

Definition at line 81 of file SharedPtrImpl.hh.

template<class T >
template<class U >
BIAS::SharedPtr< T >::SharedPtr ( const SharedPtr< U > &  pt)

needed to enable assignement of SharedPtr<T> to SharedPtr<const T>

Definition at line 95 of file SharedPtrImpl.hh.

template<class T>
BIAS::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  pt)

Definition at line 86 of file SharedPtrImpl.hh.

template<class T>
BIAS::SharedPtr< T >::SharedPtr ( T *  pt)
explicit

Definition at line 109 of file SharedPtrImpl.hh.

template<class T >
BIAS::SharedPtr< T >::~SharedPtr ( )
virtual

Definition at line 121 of file SharedPtrImpl.hh.

Member Function Documentation

template<class T >
template<class U >
SharedPtr< T > BIAS::SharedPtr< T >::ConstCast ( const SharedPtr< U > &  rs)

eqivalent to *this = const_cast<SharedPtr<T> >(rs)

Definition at line 251 of file SharedPtrImpl.hh.

References BIAS::Get().

Referenced by BIAS::SharedPtr< T >::ConstCast().

template<class T >
template<class U >
SharedPtr< T > BIAS::SharedPtr< T >::DynamicCast ( const SharedPtr< U > &  rs)

eqivalent to *this = dynamic_cast<SharedPtr<T> >(rs)

Definition at line 237 of file SharedPtrImpl.hh.

References BIAS::Get().

Referenced by BIAS::SharedPtr< T >::DynamicCast().

template<class T >
BIAS::SharedPtr< T >::operator Tester * ( ) const

Enable the expression "if (ptr)", while at the same time preventing "delete ptr" from compilling.

enable the expression "if (ptr)", see Alexandrescu "Modern C++ design", chap 7.8, p 178

This is done by providing an automatic conversion operator to the "Tester" class. The tester class itself introduces an additional "delete" function and thus makes "delete ptr" ambiguous. See Alexandrescu "Modern C++ design", chap 7.8, p 178

Definition at line 177 of file SharedPtrImpl.hh.

template<class T >
bool BIAS::SharedPtr< T >::operator! ( ) const

enable the expression "if (!ptr)"

Definition at line 169 of file SharedPtrImpl.hh.

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator!= ( const SharedPtr< U > &  rs) const

Definition at line 197 of file SharedPtrImpl.hh.

References BIAS::Get().

template<class T >
T & BIAS::SharedPtr< T >::operator* ( ) const

Definition at line 140 of file SharedPtrImpl.hh.

template<class T >
T * BIAS::SharedPtr< T >::operator-> ( ) const

Definition at line 152 of file SharedPtrImpl.hh.

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator< ( const SharedPtr< U > &  rs) const

ordering

Definition at line 208 of file SharedPtrImpl.hh.

References BIAS::Get().

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator<= ( const SharedPtr< U > &  rs) const

Definition at line 214 of file SharedPtrImpl.hh.

References BIAS::Get().

template<class T>
SharedPtr< T > & BIAS::SharedPtr< T >::operator= ( const SharedPtr< T > &  sp)

Definition at line 127 of file SharedPtrImpl.hh.

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator== ( const SharedPtr< U > &  rs) const

comparisons

Definition at line 190 of file SharedPtrImpl.hh.

References BIAS::Get().

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator> ( const SharedPtr< U > &  rs) const

Definition at line 220 of file SharedPtrImpl.hh.

References BIAS::Get().

template<class T >
template<class U >
bool BIAS::SharedPtr< T >::operator>= ( const SharedPtr< U > &  rs) const

Definition at line 226 of file SharedPtrImpl.hh.

References BIAS::Get().

Friends And Related Function Documentation

template<class T , class U >
SharedPtr< T > ConstCast ( const SharedPtr< U > &  src)
related

DynamicCast function.

Author
woelk 02/2008

Definition at line 70 of file SharedPtrImpl.hh.

References BIAS::SharedPtr< T >::ConstCast().

template<class T , class U >
SharedPtr< T > DynamicCast ( const SharedPtr< U > &  src)
related

DynamicCast function.

Author
woelk 02/2008

Definition at line 60 of file SharedPtrImpl.hh.

References BIAS::SharedPtr< T >::DynamicCast().

template<class T >
T * Get ( SharedPtr< T > &  t)
related

access function to the raw pointer

Author
woelk 09/2007

Definition at line 39 of file SharedPtrImpl.hh.

template<class T >
T *const Get ( const SharedPtr< T > &  t)
related

access function to the raw pointer

Author
woelk 09/2007

Definition at line 46 of file SharedPtrImpl.hh.

template<class T>
T* Get ( SharedPtr< T > &  t)
friend

access functions

template<class T>
T* const Get ( const SharedPtr< T > &  t)
friend
template<class T>
std::ostream& operator<< ( std::ostream &  os,
const SharedPtr< T > &  t 
)
friend

stream operator

template<class T >
unsigned RefCount ( const SharedPtr< T > &  t)
related

access function to the reference count

Author
woelk 09/2007

Definition at line 53 of file SharedPtrImpl.hh.

template<class T>
unsigned RefCount ( const SharedPtr< T > &  t)
friend
template<class T>
template<class U >
friend class SharedPtr
friend

Definition at line 148 of file SharedPtr.hh.


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