ITK  5.3.0
Insight Toolkit
Public Types | Public Member Functions | List of all members
itk::AutoPointer< TObjectType > Class Template Reference

#include <itkAutoPointer.h>

Public Types

using ObjectType = TObjectType
 
using Self = AutoPointer
 

Public Member Functions

 AutoPointer ()
 
ObjectTypem_Pointer
 
bool m_IsOwner { false }
 
 AutoPointer (AutoPointer &p)
 
 AutoPointer (ObjectType *p, bool takeOwnership)
 
 ~AutoPointer ()
 
ObjectTypeoperator-> () const
 
void Reset ()
 
void TakeOwnership ()
 
void TakeOwnership (ObjectType *objectptr)
 
void TakeNoOwnership (ObjectType *objectptr)
 
bool IsOwner () const
 
ObjectTypeReleaseOwnership ()
 
ObjectTypeGetPointer () const
 
bool operator== (const AutoPointer &r) const
 
bool operator!= (const AutoPointer &r) const
 
bool operator< (const AutoPointer &r) const
 
bool operator> (const AutoPointer &r) const
 
bool operator<= (const AutoPointer &r) const
 
bool operator>= (const AutoPointer &r) const
 
AutoPointeroperator= (AutoPointer &r)
 
 operator bool () const
 
void Swap (AutoPointer &r) noexcept
 

Detailed Description

template<typename TObjectType>
class itk::AutoPointer< TObjectType >

Implements an Automatic Pointer to an object.

AutoPointer is intended to facilitate the construction of objects on the fly for those objects that are not to be shared. An AutoPointer destroys its object when it goes out of scope. Ownership of the object is transferred from one AutoPointer to another AutoPointer when the assignment operator is used. An AutoPointer can release ownership of the object it holds.

This class follows the design of the std::unique_ptr (auto_ptr being deprecated in C++11) class. The main * reason for not using the std version is to avoid templated methods, which greatly increase the difficulty of wrapping for Tcl, Python and Java.

Definition at line 46 of file itkAutoPointer.h.

Member Typedef Documentation

◆ ObjectType

template<typename TObjectType>
using itk::AutoPointer< TObjectType >::ObjectType = TObjectType

Extract information from template parameter.

Definition at line 50 of file itkAutoPointer.h.

◆ Self

template<typename TObjectType>
using itk::AutoPointer< TObjectType >::Self = AutoPointer

Definition at line 51 of file itkAutoPointer.h.

Constructor & Destructor Documentation

◆ AutoPointer() [1/3]

template<typename TObjectType>
itk::AutoPointer< TObjectType >::AutoPointer ( )
inline

Constructor.

Definition at line 54 of file itkAutoPointer.h.

Referenced by itk::AutoPointer< TObjectType >::operator=().

◆ AutoPointer() [2/3]

template<typename TObjectType>
itk::AutoPointer< TObjectType >::AutoPointer ( AutoPointer< TObjectType > &  p)
inlineexplicit

◆ AutoPointer() [3/3]

template<typename TObjectType>
itk::AutoPointer< TObjectType >::AutoPointer ( ObjectType p,
bool  takeOwnership 
)
inlineexplicit

Constructor to pointer p.

Definition at line 68 of file itkAutoPointer.h.

◆ ~AutoPointer()

template<typename TObjectType>
itk::AutoPointer< TObjectType >::~AutoPointer ( )
inline

Destructor.

Definition at line 74 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::Reset().

Member Function Documentation

◆ GetPointer()

template<typename TObjectType>
ObjectType* itk::AutoPointer< TObjectType >::GetPointer ( ) const
inline

Access function to pointer.

Definition at line 155 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ IsOwner()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::IsOwner ( ) const
inline

Query for the ownership

Definition at line 128 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner.

Referenced by itk::AutoPointer< TObjectType >::AutoPointer(), and itk::operator<<().

◆ operator bool()

template<typename TObjectType>
itk::AutoPointer< TObjectType >::operator bool ( ) const
inline

Casting operator to boolean. This is used in conditional statements to check the content of the pointer against null

Definition at line 213 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator!=()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator!= ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. NonEqual comparison.

Definition at line 169 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator->()

template<typename TObjectType>
ObjectType* itk::AutoPointer< TObjectType >::operator-> ( ) const
inline

Overload operator ->.

Definition at line 77 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator<()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator< ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. Less than comparison.

Definition at line 176 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator<=()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator<= ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. Less than or equal to comparison.

Definition at line 190 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator=()

template<typename TObjectType>
AutoPointer& itk::AutoPointer< TObjectType >::operator= ( AutoPointer< TObjectType > &  r)
inline

Overload operator assignment.

Definition at line 204 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::AutoPointer().

◆ operator==()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator== ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. Equal comparison.

Definition at line 162 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator>()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator> ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. Greater than comparison.

Definition at line 183 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ operator>=()

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::operator>= ( const AutoPointer< TObjectType > &  r) const
inline

Comparison of pointers. Greater than or equal to comparison.

Definition at line 197 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ ReleaseOwnership()

template<typename TObjectType>
ObjectType* itk::AutoPointer< TObjectType >::ReleaseOwnership ( )
inline

Release the pointer hold by the current AutoPointer and return the raw pointer so it can be hold by another AutoPointer. This operation is intended to be used for facilitating polymorphism.

Example: if class Cow derives from Mammal, AutoPointer<Cow> onecow = new Cow; AutoPointer<Mammal> onemammal = onecow.ReleaseOwnership();

Note that the AutoPointer still points to the object after the ReleaseOwnership operation, but it doesn't own the object any more.

Definition at line 146 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner, and itk::AutoPointer< TObjectType >::m_Pointer.

Referenced by itk::AutoPointer< TObjectType >::AutoPointer().

◆ Reset()

template<typename TObjectType>
void itk::AutoPointer< TObjectType >::Reset ( )
inline

Clear the AutoPointer. If it had a pointer the object is deleted and the pointer is set to null.

Definition at line 82 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner, and itk::AutoPointer< TObjectType >::m_Pointer.

Referenced by itk::AutoPointer< TObjectType >::~AutoPointer().

◆ Swap()

template<typename TObjectType>
void itk::AutoPointer< TObjectType >::Swap ( AutoPointer< TObjectType > &  r)
inlineprivatenoexcept

Function to print object pointed to.
Exchange the content of two AutoPointers

Definition at line 229 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_Pointer.

◆ TakeNoOwnership()

template<typename TObjectType>
void itk::AutoPointer< TObjectType >::TakeNoOwnership ( ObjectType objectptr)
inline

Explicitly reject ownership

Definition at line 115 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner, and itk::AutoPointer< TObjectType >::m_Pointer.

◆ TakeOwnership() [1/2]

template<typename TObjectType>
void itk::AutoPointer< TObjectType >::TakeOwnership ( )
inline

Explicitly set the ownership

Definition at line 95 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner.

◆ TakeOwnership() [2/2]

template<typename TObjectType>
void itk::AutoPointer< TObjectType >::TakeOwnership ( ObjectType objectptr)
inline

Explicitly set the ownership

Definition at line 102 of file itkAutoPointer.h.

References itk::AutoPointer< TObjectType >::m_IsOwner, and itk::AutoPointer< TObjectType >::m_Pointer.

Member Data Documentation

◆ m_IsOwner

template<typename TObjectType>
bool itk::AutoPointer< TObjectType >::m_IsOwner { false }
private

◆ m_Pointer

template<typename TObjectType>
ObjectType* itk::AutoPointer< TObjectType >::m_Pointer
private

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