|
DCMTK
Version 3.6.9
OFFIS DICOM Toolkit
|
OFshared_ptr is a smart pointer that retains shared ownership of an object through a pointer. More...
Classes | |
| class | Data |
| Helper class containing the reference to the managed object and the reference counter. More... | |
Public Member Functions | |
| OFshared_ptr (T *const pt=OFnullptr) | |
| Constructs a shared_ptr with pt as the managed object. More... | |
| OFshared_ptr (const OFshared_ptr &other) | |
| Constructs a shared_ptr which shares ownership of the object managed by other. More... | |
| OFshared_ptr & | operator= (const OFshared_ptr &other) |
| Replaces the managed object with the one managed by other. More... | |
| ~OFshared_ptr () | |
| If *this owns an object and it is the last shared_ptr owning it, the object is destroyed. More... | |
| operator OFBool () const | |
| Checks if *this manages an object, i.e. More... | |
| OFBool | operator! () const |
| Checks if *this does not manage an object, i.e. More... | |
| T & | operator* () const |
| Dereferences pointer to the managed object. More... | |
| T * | operator-> () const |
| Dereferences pointer to the managed object. More... | |
| T * | get () const |
| Returns a pointer to the managed object. More... | |
| void | reset (T *const pt=OFnullptr) |
| Replaces the managed object with an object pointed to by pt. More... | |
Private Member Functions | |
| void | destroy () |
| decrement the reference counter, destroy the managed object and the counter if the counter reached zero. | |
Private Attributes | |
| Data * | m_pData |
| A pointer to the management data structure containing the actual reference to the managed object and the reference counter. | |
OFshared_ptr is a smart pointer that retains shared ownership of an object through a pointer.
Several OFshared_ptr objects may own the same object; the object is destroyed when the last remaining OFshared_ptr referring to it is destroyed or reset.
An OFshared_ptr may also own no objects, in which case it is called empty.
OFshared_ptr meets the requirements of CopyConstructible and CopyAssignable.
| T | the type of the managed object, e.g. int for an OFshared_ptr behaving like an int*. |
|
inline |
Constructs a shared_ptr with pt as the managed object.
| pt | the managed object that this shared_ptr takes the ownership to. |
|
inline |
Constructs a shared_ptr which shares ownership of the object managed by other.
If other manages no object, *this manages no object too.
| other | another shared_ptr that this one will be copy constructed from. |
References OFshared_ptr< T >::Data::increment_count(), and OFshared_ptr< T >::m_pData.
|
inline |
If *this owns an object and it is the last shared_ptr owning it, the object is destroyed.
Otherwise does nothing.
References OFshared_ptr< T >::destroy().
|
inline |
Returns a pointer to the managed object.
References OFshared_ptr< T >::m_pData, and OFshared_ptr< T >::Data::pointer().
|
inline |
Checks if *this manages an object, i.e.
whether get() != 0.
|
inline |
Checks if *this does not manage an object, i.e.
whether get() == 0.
References OFshared_ptr< T >::m_pData, and OFshared_ptr< T >::Data::pointer().
|
inline |
Dereferences pointer to the managed object.
References OFshared_ptr< T >::m_pData, and OFshared_ptr< T >::Data::pointer().
|
inline |
Dereferences pointer to the managed object.
References OFshared_ptr< T >::m_pData, and OFshared_ptr< T >::Data::pointer().
|
inline |
Replaces the managed object with the one managed by other.
| other | another shared_ptr that this one will be copy assigned from. |
References OFshared_ptr< T >::destroy(), OFshared_ptr< T >::Data::increment_count(), and OFshared_ptr< T >::m_pData.
|
inline |
Replaces the managed object with an object pointed to by pt.
| pt | pointer to an object to acquire ownership of. |
References OFshared_ptr< T >::destroy(), and OFshared_ptr< T >::m_pData.