DGtal
0.6.devel
|
#include <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.
|
inline |
Constructor with copy.
aValue | value, myPtr owns a copy of which. |
Definition at line 44 of file OwningOrAliasingPtr.ih.
|
inline |
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). |
Definition at line 51 of file OwningOrAliasingPtr.ih.
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 58 of file OwningOrAliasingPtr.ih.
References DGtal::OwningOrAliasingPtr< T >::myFlagIsOwning, and DGtal::OwningOrAliasingPtr< T >::myPtr.
|
inline |
Destructor.
Definition at line 90 of file OwningOrAliasingPtr.ih.
|
private |
|
inline |
Access to the underlying pointer.
Definition at line 103 of file OwningOrAliasingPtr.ih.
|
inline |
Tells whether the pointer owns the data or not.
Definition at line 128 of file OwningOrAliasingPtr.ih.
|
inline |
Checks the validity/consistency of the object.
Definition at line 136 of file OwningOrAliasingPtr.ih.
|
inline |
|
inline |
|
inline |
Assignment.
other | the object to copy. |
Definition at line 71 of file OwningOrAliasingPtr.ih.
References DGtal::OwningOrAliasingPtr< T >::myFlagIsOwning, and DGtal::OwningOrAliasingPtr< T >::myPtr.
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 144 of file OwningOrAliasingPtr.ih.
|
private |
Boolean that is equal to 'true' if myPtr owns the data 'false' otherwise
Definition at line 172 of file OwningOrAliasingPtr.h.
Referenced by DGtal::OwningOrAliasingPtr< T >::operator=(), and DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr().
|
private |
Owning or aliasing pointer to the data
Definition at line 166 of file OwningOrAliasingPtr.h.
Referenced by DGtal::OwningOrAliasingPtr< T >::operator=(), and DGtal::OwningOrAliasingPtr< T >::OwningOrAliasingPtr().