MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Public Types | Public Member Functions | Friends
mds::base::CSharedPtr< T > Class Template Reference

Smart pointer to a shared object providing intrusive reference counting. More...

#include <mdsSharedPtr.h>

List of all members.

Public Types

enum  { TEMPLATE_PARAMETER_IS_NOT_OBJECT = T::CLASS_OBJECT }
 Check that T is derived from CObject class. More...
typedef T tPointee
 Pointee type.
typedef T * tPointer
 Stored pointer type.

Public Member Functions

 CSharedPtr ()
 Default constructor.
 CSharedPtr (T *p)
 Constructor from a raw pointer.
 CSharedPtr (const CSharedPtr &p)
 Constructor from a raw pointer.
T * get ()
 Returns pointer to the encapsulated object.
const T * get () const
 operator T * ()
 Conversion to the raw pointer.
 operator void * ()
 Added conversion to the void pointer to avoid raw pointer deletion.
bool operator! () const
 Enables "if (!sp) ...".
template<typename U >
bool operator!= (const CSharedPtr< U > &r) const
T & operator* () const
 Returns reference to the stored object.
T * operator-> () const
 Returns pointer to the encapsulated object.
template<typename U >
bool operator< (const CSharedPtr< U > &r) const
CSharedPtroperator= (const CSharedPtr &p)
 Assignment operator.
CSharedPtroperator= (T *p)
 Assignment operator.
template<typename U >
bool operator== (const CSharedPtr< U > &r) const
 Ambiguity buster solving the comparision of two smart pointers.
T * release ()
 Returns pointer to the encapsulated object and decreases the reference counter.
 ~CSharedPtr ()
 Assignment operator.

Friends

bool operator!= (const CSharedPtr &l, const T *r)
bool operator!= (const T *l, const CSharedPtr &r)
template<typename U >
bool operator!= (const CSharedPtr &l, const U *r)
template<typename U >
bool operator!= (const U *l, const CSharedPtr &r)
bool operator< (const CSharedPtr &l, const T *r)
bool operator< (const T *l, const CSharedPtr &r)
template<typename U >
bool operator< (const CSharedPtr &l, const U *r)
template<typename U >
bool operator< (const U *l, const CSharedPtr &r)
bool operator== (const CSharedPtr &l, const T *r)
 Comparision operators.
bool operator== (const T *l, const CSharedPtr &r)
template<typename U >
bool operator== (const CSharedPtr &l, const U *r)
 Ambiquity buster that solves problem using comparision like "if( p == sp ) ...".
template<typename U >
bool operator== (const U *l, const CSharedPtr &r)

Detailed Description

template<typename T>
class mds::base::CSharedPtr< T >

Smart pointer to a shared object providing intrusive reference counting.

Once the pointer is initialized, it takes control over the object deletion.


Member Typedef Documentation

template<typename T >
typedef T mds::base::CSharedPtr< T >::tPointee

Pointee type.

template<typename T >
typedef T* mds::base::CSharedPtr< T >::tPointer

Stored pointer type.


Member Enumeration Documentation

template<typename T >
anonymous enum

Check that T is derived from CObject class.

Otherwise, you will see name of this enum somewhere in compiler error message.

Enumerator:
TEMPLATE_PARAMETER_IS_NOT_OBJECT 

Constructor & Destructor Documentation

template<typename T >
mds::base::CSharedPtr< T >::CSharedPtr ( )

Default constructor.

  • Internal pointer is initialized to the NULL.
  • Use with care! Default constructor.
  • Uses default pointee type constructor.
template<typename T >
mds::base::CSharedPtr< T >::CSharedPtr ( T *  p)

Constructor from a raw pointer.

  • NULL can be given.
template<typename T >
mds::base::CSharedPtr< T >::CSharedPtr ( const CSharedPtr< T > &  p)

Constructor from a raw pointer.

Copy constructor.

  • Makes a new reference to the object.
template<typename T >
mds::base::CSharedPtr< T >::~CSharedPtr ( )

Assignment operator.

  • Makes a new reference to the object. Destructor.

Member Function Documentation

template<typename T >
T* mds::base::CSharedPtr< T >::get ( )

Returns pointer to the encapsulated object.

template<typename T >
const T* mds::base::CSharedPtr< T >::get ( ) const
template<typename T >
mds::base::CSharedPtr< T >::operator T * ( )

Conversion to the raw pointer.

template<typename T >
mds::base::CSharedPtr< T >::operator void * ( )

Added conversion to the void pointer to avoid raw pointer deletion.

template<typename T >
bool mds::base::CSharedPtr< T >::operator! ( ) const

Enables "if (!sp) ...".

template<typename T >
template<typename U >
bool mds::base::CSharedPtr< T >::operator!= ( const CSharedPtr< U > &  r) const
template<typename T >
T& mds::base::CSharedPtr< T >::operator* ( ) const

Returns reference to the stored object.

template<typename T >
T* mds::base::CSharedPtr< T >::operator-> ( ) const

Returns pointer to the encapsulated object.

template<typename T >
template<typename U >
bool mds::base::CSharedPtr< T >::operator< ( const CSharedPtr< U > &  r) const
template<typename T >
CSharedPtr& mds::base::CSharedPtr< T >::operator= ( const CSharedPtr< T > &  p)

Assignment operator.

  • Makes a new reference to the object.
template<typename T >
CSharedPtr& mds::base::CSharedPtr< T >::operator= ( T *  p)

Assignment operator.

  • Makes a new reference to the object.
template<typename T >
template<typename U >
bool mds::base::CSharedPtr< T >::operator== ( const CSharedPtr< U > &  r) const

Ambiguity buster solving the comparision of two smart pointers.

template<typename T >
T* mds::base::CSharedPtr< T >::release ( )

Returns pointer to the encapsulated object and decreases the reference counter.

Sets the internal pointer to NULL to avoid destruction of the object.

  • Use with care!

Friends And Related Function Documentation

template<typename T >
bool operator!= ( const CSharedPtr< T > &  l,
const T *  r 
) [friend]
template<typename T >
bool operator!= ( const T *  l,
const CSharedPtr< T > &  r 
) [friend]
template<typename T >
template<typename U >
bool operator!= ( const CSharedPtr< T > &  l,
const U *  r 
) [friend]
template<typename T >
template<typename U >
bool operator!= ( const U *  l,
const CSharedPtr< T > &  r 
) [friend]
template<typename T >
bool operator< ( const CSharedPtr< T > &  l,
const T *  r 
) [friend]
template<typename T >
bool operator< ( const T *  l,
const CSharedPtr< T > &  r 
) [friend]
template<typename T >
template<typename U >
bool operator< ( const CSharedPtr< T > &  l,
const U *  r 
) [friend]
template<typename T >
template<typename U >
bool operator< ( const U *  l,
const CSharedPtr< T > &  r 
) [friend]
template<typename T >
bool operator== ( const CSharedPtr< T > &  l,
const T *  r 
) [friend]

Comparision operators.

template<typename T >
bool operator== ( const T *  l,
const CSharedPtr< T > &  r 
) [friend]
template<typename T >
template<typename U >
bool operator== ( const CSharedPtr< T > &  l,
const U *  r 
) [friend]

Ambiquity buster that solves problem using comparision like "if( p == sp ) ...".

template<typename T >
template<typename U >
bool operator== ( const U *  l,
const CSharedPtr< T > &  r 
) [friend]

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