Public Types | Public Member Functions | Private Member Functions | Private Attributes

DGtal::CowPtr< T > Class Template Reference

Aim: Copy on write shared pointer. More...

#include <CowPtr.h>

Inheritance diagram for DGtal::CowPtr< T >:
Inheritance graph
[legend]

Public Types

typedef T element_type

Public Member Functions

 CowPtr (T *p=0) throw ()
 CowPtr (const CowPtr &r) throw ()
 CowPtr (const CountedPtr< T > &r)
CowPtroperator= (const CowPtr &r)
const T & operator* () const throw ()
const T * operator-> () const throw ()
const T * get () const throw ()
T & operator* ()
T * operator-> ()
T * get ()
unsigned int count () const
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

void copy ()

Private Attributes

CountedPtr< T > myPtr

Detailed Description

template<typename T>
class DGtal::CowPtr< T >

Aim: Copy on write shared pointer.

Description of template class 'CowPtr'

Use reference counting as long as the pointed object is not modified. When it is about to be modified, copy it and modify the copy.

Taken from http://ootips.org/yonat/4dev/smart-pointers.html


Member Typedef Documentation

template<typename T>
typedef T DGtal::CowPtr< T >::element_type

Constructor & Destructor Documentation

template<typename T>
DGtal::CowPtr< T >::CowPtr ( T *  p = 0  )  throw () [inline, explicit]
template<typename T>
DGtal::CowPtr< T >::CowPtr ( const CowPtr< T > &  r  )  throw () [inline]
template<typename T>
DGtal::CowPtr< T >::CowPtr ( const CountedPtr< T > &  r  )  [inline]
Todo:
JOL: check this.

Member Function Documentation

template<typename T>
void DGtal::CowPtr< T >::copy (  )  [inline, private]
template<typename T>
unsigned int DGtal::CowPtr< T >::count (  )  const [inline]

For debug.

template<typename T>
const T* DGtal::CowPtr< T >::get (  )  const throw () [inline]
template<typename T>
T* DGtal::CowPtr< T >::get (  )  [inline]
template<typename T>
bool DGtal::CowPtr< T >::isValid (  )  const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
template<typename T>
T& DGtal::CowPtr< T >::operator* (  )  [inline]
template<typename T>
const T& DGtal::CowPtr< T >::operator* (  )  const throw () [inline]
template<typename T>
const T* DGtal::CowPtr< T >::operator-> (  )  const throw () [inline]
template<typename T>
T* DGtal::CowPtr< T >::operator-> (  )  [inline]
template<typename T>
CowPtr& DGtal::CowPtr< T >::operator= ( const CowPtr< T > &  r  )  [inline]
template<typename T>
void DGtal::CowPtr< T >::selfDisplay ( std::ostream &  out  )  const

Writes/Displays the object on an output stream.

Parameters:
out the output stream where the object is written.

Field Documentation

template<typename T>
CountedPtr<T> DGtal::CowPtr< T >::myPtr [private]

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