DCMTK  Version 3.6.1 20131114
OFFIS DICOM Toolkit
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
OFunique_ptr< T > Class Template Reference

OFunique_ptr is a smart pointer that retains sole ownership of an object through a pointer and destroys that object when the unique_ptr goes out of scope. More...

Public Types

typedef T * pointer
 typedef of pointer type T* for template programmers.
 
typedef T element_type
 T, the type of the object managed by this unique_ptr.
 

Public Member Functions

 OFunique_ptr ()
 Constructs an empty OFunique_ptr.
 
 OFunique_ptr (pointer p)
 Constructs a OFunique_ptr which owns p. More...
 
 ~OFunique_ptr ()
 If get() == NULL there are no effects – otherwise, the owned object is destroyed.
 
void reset (pointer p=NULL)
 Replaces the managed object. More...
 
pointer release ()
 Releases the ownership of the managed object if any. More...
 
pointer get () const
 Returns a pointer to the managed object or NULL if no object is owned. More...
 
 operator bool () const
 Checks whether *this owns an object, i.e. More...
 
bool operator! () const
 Checks whether *this does NOT own an object, i.e. More...
 
T & operator* () const
 Access the object owned by *this. More...
 
pointer operator-> () const
 Access the object owned by *this. More...
 

Private Member Functions

 OFunique_ptr (const OFunique_ptr &)
 Disable copy construction.
 
OFunique_ptroperator= (const OFunique_ptr &)
 Disable copy assignment.
 

Private Attributes

pointer m_pData
 The underlying (raw) pointer.
 

Detailed Description

template<typename T>
class OFunique_ptr< T >

OFunique_ptr is a smart pointer that retains sole ownership of an object through a pointer and destroys that object when the unique_ptr goes out of scope.

No two unique_ptr instances can manage the same object.

The object is destroyed and its memory deallocated when either of the following happens:

A unique_ptr may also own no objects, in which case it is called empty.

OFunique_ptr is NOT CopyConstructible or CopyAssignable.

Template Parameters
Tthe type of the managed object, e.g. int for an OFunique_ptr behaving like an int*.
Note
this implementation is meant to be a subset of the c++11's std::unique_ptr that lacks the following features: swap support, custom deleters, move support, specialized handling of pointers to arrays and some functions like comparing OFunique_ptrs or creating a hash key. see http://en.cppreference.com/w/cpp/memory/unique_ptr to compare OFunique_ptr against std::unique_ptr.

Constructor & Destructor Documentation

template<typename T >
OFunique_ptr< T >::OFunique_ptr ( pointer  p)
inlineexplicit

Constructs a OFunique_ptr which owns p.

Parameters
pthe pointer that's going to be owned by this unique_ptr.

Member Function Documentation

template<typename T >
pointer OFunique_ptr< T >::get ( ) const
inline

Returns a pointer to the managed object or NULL if no object is owned.

Returns
Pointer to the managed object or NULL if no object is owned.

References OFunique_ptr< T >::m_pData.

template<typename T >
OFunique_ptr< T >::operator bool ( ) const
inline

Checks whether *this owns an object, i.e.

whether get() != NULL.

Returns
get() != NULL.

References OFunique_ptr< T >::m_pData.

template<typename T >
bool OFunique_ptr< T >::operator! ( ) const
inline

Checks whether *this does NOT own an object, i.e.

whether get() == NULL.

Returns
get() == NULL.

References OFunique_ptr< T >::m_pData.

template<typename T >
T& OFunique_ptr< T >::operator* ( ) const
inline

Access the object owned by *this.

Returns
the object owned by *this, i.e. *get().

References OFunique_ptr< T >::m_pData.

template<typename T >
pointer OFunique_ptr< T >::operator-> ( ) const
inline

Access the object owned by *this.

Returns
same as get().

References OFunique_ptr< T >::m_pData.

template<typename T >
pointer OFunique_ptr< T >::release ( )
inline

Releases the ownership of the managed object if any.

Retrieves the owned object (if any) and lets the unique_ptr become empty.

Returns
same as get().

References OFunique_ptr< T >::m_pData.

template<typename T >
void OFunique_ptr< T >::reset ( pointer  p = NULL)
inline

Replaces the managed object.

The previously owned object is deleted if the unique_ptr was not empty.

Parameters
pthe new pointer to be owned, defaults to NULL.

References OFunique_ptr< T >::m_pData.


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


Generated on Tue Nov 26 2013 for DCMTK Version 3.6.1 20131114 by Doxygen 1.8.5