ITK
6.0.0
Insight Toolkit
|
#include <itkAutoPointer.h>
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.
Public Types | |
using | ObjectType = TObjectType |
using | Self = AutoPointer |
Public Member Functions | |
AutoPointer () | |
AutoPointer (ObjectType *p, bool takeOwnership) | |
ObjectType * | GetPointer () const |
bool | IsOwner () const |
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION (Self) | |
operator bool () const | |
ObjectType * | operator-> () 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 |
void | TakeOwnership () |
~AutoPointer () | |
AutoPointer (AutoPointer &p) | |
void | Reset () |
void | TakeOwnership (ObjectType *objectptr) |
void | TakeNoOwnership (ObjectType *objectptr) |
ObjectType * | ReleaseOwnership () |
AutoPointer & | operator= (AutoPointer &r) |
Private Member Functions | |
void | Swap (AutoPointer &r) noexcept |
Private Attributes | |
bool | m_IsOwner { false } |
ObjectType * | m_Pointer |
using itk::AutoPointer< TObjectType >::ObjectType = TObjectType |
Extract information from template parameter.
Definition at line 50 of file itkAutoPointer.h.
using itk::AutoPointer< TObjectType >::Self = AutoPointer |
Definition at line 51 of file itkAutoPointer.h.
|
inline |
Constructor.
Definition at line 54 of file itkAutoPointer.h.
Referenced by itk::AutoPointer< TObjectType >::operator=().
|
inlineexplicit |
Copy constructor.
Definition at line 59 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::IsOwner(), itk::AutoPointer< TObjectType >::m_IsOwner, itk::AutoPointer< TObjectType >::m_Pointer, and itk::AutoPointer< TObjectType >::ReleaseOwnership().
|
inlineexplicit |
Constructor to pointer p.
Definition at line 68 of file itkAutoPointer.h.
|
inline |
Destructor.
Definition at line 74 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::Reset().
|
inline |
Access function to pointer.
Definition at line 155 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
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<<().
itk::AutoPointer< TObjectType >::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION | ( | Self | ) |
|
inline |
Casting operator to boolean. This is used in conditional statements to check the content of the pointer against null
Definition at line 208 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Overload operator ->.
Definition at line 77 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Comparison of pointers. Less than comparison.
Definition at line 171 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Comparison of pointers. Less than or equal to comparison.
Definition at line 185 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Overload operator assignment.
Definition at line 199 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::AutoPointer().
|
inline |
Comparison of pointers. Equal comparison.
Definition at line 162 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Comparison of pointers. Greater than comparison.
Definition at line 178 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Comparison of pointers. Greater than or equal to comparison.
Definition at line 192 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
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().
|
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().
|
inlineprivatenoexcept |
Function to print object pointed to.
Exchange the content of two AutoPointers
Definition at line 224 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Explicitly reject ownership
Definition at line 115 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_IsOwner, and itk::AutoPointer< TObjectType >::m_Pointer.
|
inline |
Explicitly set the ownership
Definition at line 95 of file itkAutoPointer.h.
References itk::AutoPointer< TObjectType >::m_IsOwner.
|
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.
|
private |
Definition at line 234 of file itkAutoPointer.h.
Referenced by itk::AutoPointer< TObjectType >::AutoPointer(), itk::AutoPointer< TObjectType >::IsOwner(), itk::AutoPointer< TObjectType >::ReleaseOwnership(), itk::AutoPointer< TObjectType >::Reset(), itk::AutoPointer< TObjectType >::TakeNoOwnership(), and itk::AutoPointer< TObjectType >::TakeOwnership().
|
private |
The pointer to the object referred to by this smart pointer.
Definition at line 233 of file itkAutoPointer.h.
Referenced by itk::AutoPointer< TObjectType >::AutoPointer(), itk::AutoPointer< TObjectType >::GetPointer(), itk::AutoPointer< TObjectType >::operator bool(), itk::AutoPointer< TObjectType >::operator->(), itk::AutoPointer< TObjectType >::operator<(), itk::AutoPointer< TObjectType >::operator<=(), itk::AutoPointer< TObjectType >::operator==(), itk::AutoPointer< TObjectType >::operator>(), itk::AutoPointer< TObjectType >::operator>=(), itk::AutoPointer< TObjectType >::ReleaseOwnership(), itk::AutoPointer< TObjectType >::Reset(), itk::AutoPointer< TObjectType >::Swap(), itk::AutoPointer< TObjectType >::TakeNoOwnership(), and itk::AutoPointer< TObjectType >::TakeOwnership().