DGtal 1.3.0
|
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. More...
#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) | |
OwningOrAliasingPtr & | operator= (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 |
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.
T | a model of boost::CopyConstructible |
Definition at line 72 of file OwningOrAliasingPtr.h.
typedef T* DGtal::OwningOrAliasingPtr< T >::Pointer |
Definition at line 80 of file OwningOrAliasingPtr.h.
typedef T& DGtal::OwningOrAliasingPtr< T >::Reference |
Definition at line 81 of file OwningOrAliasingPtr.h.
typedef T DGtal::OwningOrAliasingPtr< T >::Value |
Definition at line 79 of file OwningOrAliasingPtr.h.
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr | ( | const T & | aValue | ) |
Constructor with copy.
aValue | value, myPtr owns a copy of which. |
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr | ( | Pointer | aPtr, |
bool | isOwning = false |
||
) |
Constructor without copy.
aPtr | any pointer assigned to myPtr |
isOwning | 'true' if myPtr must be an owning pointer 'false' if myPtr must be only an alias (default). |
DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr | ( | const OwningOrAliasingPtr< T > & | other | ) |
Copy constructor.
other | the object to clone. |
DGtal::OwningOrAliasingPtr< T >::~OwningOrAliasingPtr | ( | ) |
Destructor.
|
private |
Pointer DGtal::OwningOrAliasingPtr< T >::get | ( | ) | const |
bool DGtal::OwningOrAliasingPtr< T >::isOwning | ( | ) | const |
Tells whether the pointer owns the data or not.
Referenced by testOwningOrAliasingPtr().
bool DGtal::OwningOrAliasingPtr< T >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Referenced by testOwningOrAliasingPtr().
Reference DGtal::OwningOrAliasingPtr< T >::operator* | ( | ) | const |
Dereferencement.
Pointer DGtal::OwningOrAliasingPtr< T >::operator-> | ( | ) | const |
Indirection.
OwningOrAliasingPtr & DGtal::OwningOrAliasingPtr< T >::operator= | ( | const OwningOrAliasingPtr< T > & | other | ) |
Assignment.
other | the object to copy. |
void DGtal::OwningOrAliasingPtr< T >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
private |
Boolean that is equal to 'true' if myPtr owns the data 'false' otherwise
Definition at line 172 of file OwningOrAliasingPtr.h.
|
private |
Owning or aliasing pointer to the data
Definition at line 166 of file OwningOrAliasingPtr.h.