DGtal  0.9.3beta
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::OwningOrAliasingPtr< T > Class Template Reference

#include <DGtal/base/OwningOrAliasingPtr.h>

Public Types

typedef T Value
 
typedef T * Pointer
 
typedef T & Reference
 

Public Member Functions

 OwningOrAliasingPtr (const T &aValue)
 
 OwningOrAliasingPtr (Pointer aPtr, bool isOwning=false)
 
 OwningOrAliasingPtr (const OwningOrAliasingPtr &other)
 
OwningOrAliasingPtroperator= (const OwningOrAliasingPtr &other)
 
 ~OwningOrAliasingPtr ()
 
Pointer operator-> () const
 
Pointer get () const
 
Reference operator* () const
 
bool isOwning () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((boost::CopyConstructible< T >))
 

Private Attributes

Pointer myPtr
 
bool myFlagIsOwning
 

Detailed Description

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

Aim: This class describes a smart pointer that is, given the constructor called by the user, either an alias pointer on existing data or an owning pointer on a copy.

Description of template class 'OwningOrAliasingPtr'

Such a pointer may be used for a (big) member of class, which can be either given at construction (aliasing pointer) or default-constructed (owning pointer).

Such a pointer may be also used to make the user be able to decide whether the data should be copied (owning pointer) or not (aliasing pointer).

Obviously, the data are free'd at destruction in the case of an owning pointer.

Template Parameters
Ta model of boost::CopyConstructible

Definition at line 72 of file OwningOrAliasingPtr.h.

Member Typedef Documentation

template<typename T>
typedef T* DGtal::OwningOrAliasingPtr< T >::Pointer

Definition at line 80 of file OwningOrAliasingPtr.h.

template<typename T>
typedef T& DGtal::OwningOrAliasingPtr< T >::Reference

Definition at line 81 of file OwningOrAliasingPtr.h.

template<typename T>
typedef T DGtal::OwningOrAliasingPtr< T >::Value

Definition at line 79 of file OwningOrAliasingPtr.h.

Constructor & Destructor Documentation

template<typename T>
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr ( const T &  aValue)

Constructor with copy.

Parameters
aValuevalue, myPtr owns a copy of which.
template<typename T>
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr ( Pointer  aPtr,
bool  isOwning = false 
)

Constructor without copy.

Parameters
aPtrany pointer assigned to myPtr
isOwning'true' if myPtr must be an owning pointer 'false' if myPtr must be only an alias (default).
template<typename T>
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr ( const OwningOrAliasingPtr< T > &  other)

Copy constructor.

Parameters
otherthe object to clone.
template<typename T>
DGtal::OwningOrAliasingPtr< T >::~OwningOrAliasingPtr ( )

Destructor.

Member Function Documentation

template<typename T>
DGtal::OwningOrAliasingPtr< T >::BOOST_CONCEPT_ASSERT ( (boost::CopyConstructible< T >)  )
private
template<typename T>
Pointer DGtal::OwningOrAliasingPtr< T >::get ( ) const

Access to the underlying pointer.

Returns
the pointer.
template<typename T>
bool DGtal::OwningOrAliasingPtr< T >::isOwning ( ) const

Tells whether the pointer owns the data or not.

Returns
boolean equal to 'true' if myPtr owns the data 'false' otherwise.
template<typename T>
bool DGtal::OwningOrAliasingPtr< T >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename T>
Reference DGtal::OwningOrAliasingPtr< T >::operator* ( ) const

Dereferencement.

Returns
the data.
template<typename T>
Pointer DGtal::OwningOrAliasingPtr< T >::operator-> ( ) const

Indirection.

Returns
the pointer.
template<typename T>
OwningOrAliasingPtr& DGtal::OwningOrAliasingPtr< T >::operator= ( const OwningOrAliasingPtr< T > &  other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.
template<typename T>
void DGtal::OwningOrAliasingPtr< T >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

template<typename T>
bool DGtal::OwningOrAliasingPtr< T >::myFlagIsOwning
private

Boolean that is equal to 'true' if myPtr owns the data 'false' otherwise

Definition at line 172 of file OwningOrAliasingPtr.h.

template<typename T>
Pointer DGtal::OwningOrAliasingPtr< T >::myPtr
private

Owning or aliasing pointer to the data

Definition at line 166 of file OwningOrAliasingPtr.h.


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