ITK
6.0.0
Insight Toolkit
|
#include <itkSmartPointer.h>
Implements transparent reference counting.
SmartPointer implements reference counting by overloading operator -> (and *) among others. This allows natural interface to the class referred to by the pointer without having to invoke special Register()/UnRegister() methods directly.
To compile / test this class Windows: cl SmartPointerTest.cxx; .\SmartPointerTest.exe linux: c++ SmartPointerTest.cxx ./a.out other: CCcompiler SmartPointerTest.cxx ./a.out
The state of the SmartPointer after a move
is with a value of nullptr
.
Definition at line 51 of file itkSmartPointer.h.
Public Types | |
template<typename T > | |
using | EnableIfConvertible = typename std::enable_if< std::is_convertible_v< T *, TObjectType * > > |
using | ObjectType = TObjectType |
Public Member Functions | |
ObjectType * | get () const noexcept |
ObjectType * | GetPointer () const noexcept |
bool | IsNotNull () const noexcept |
bool | IsNull () const noexcept |
operator bool () const noexcept | |
operator ObjectType * () const noexcept | |
ObjectType & | operator* () const noexcept |
ObjectType * | operator-> () const noexcept |
SmartPointer & | operator= (std::nullptr_t) noexcept |
constexpr | SmartPointer () noexcept=default |
SmartPointer (const SmartPointer &p) noexcept | |
template<typename T , typename = typename EnableIfConvertible<T>::type> | |
SmartPointer (const SmartPointer< T > &p) noexcept | |
SmartPointer (ObjectType *p) noexcept | |
SmartPointer (SmartPointer< ObjectType > &&p) noexcept | |
template<typename T , typename = typename EnableIfConvertible<T>::type> | |
SmartPointer (SmartPointer< T > &&p) noexcept | |
constexpr | SmartPointer (std::nullptr_t) noexcept |
void | Swap (SmartPointer &other) noexcept |
~SmartPointer () | |
SmartPointer & | operator= (SmartPointer r) noexcept |
ObjectType * | Print (std::ostream &os) const |
Private Member Functions | |
void | Register () noexcept |
void | UnRegister () noexcept |
Private Attributes | |
ObjectType * | m_Pointer { nullptr } |
Friends | |
template<typename T > | |
class | SmartPointer |
using itk::SmartPointer< TObjectType >::EnableIfConvertible = typename std::enable_if<std::is_convertible_v<T *, TObjectType *> > |
Definition at line 57 of file itkSmartPointer.h.
using itk::SmartPointer< TObjectType >::ObjectType = TObjectType |
Definition at line 54 of file itkSmartPointer.h.
|
constexprdefaultnoexcept |
Default-constructor
|
inlinenoexcept |
Copy constructor
Definition at line 63 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::Register().
|
inlineconstexprnoexcept |
Constructor for implicit conversion from nullptr
Definition at line 70 of file itkSmartPointer.h.
|
inlinenoexcept |
constructor with implicit conversion of pointer type
Definition at line 74 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::Register().
|
inlinenoexcept |
Move constructor
Definition at line 81 of file itkSmartPointer.h.
|
inlinenoexcept |
move constructor with implicit conversion of pointer type
Definition at line 89 of file itkSmartPointer.h.
|
inlinenoexcept |
Constructor to pointer p
Definition at line 96 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::Register().
|
inline |
Destructor
Definition at line 103 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::UnRegister().
|
inlinenoexcept |
Returns the stored (raw) pointer. Equivalent to GetPointer()
, but then following the Standard C++ Library naming conversion (like std::shared_ptr::get()
).
Definition at line 140 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
|
inlinenoexcept |
Access function to pointer.
Definition at line 132 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::Transform< TParametersValueType, VInputDimension, VOutputDimension >::ApplyToImageMetadata(), itk::watershed::BoundaryResolver< TPixelType, TDimension >::BoundaryResolver(), itk::ObjectFactory< T >::Create(), itk::CreateObjectFunction< T >::CreateObject(), itk::watershed::EquivalenceRelabeler< TScalar, TImageDimension >::EquivalenceRelabeler(), itk::testhelper::ImageRegistrationMethodImageSource< TFixedPixelType, TMovingPixelType, VDimension >::GetFixedImage(), itk::GPUImageDataManager< ImageType >::GetImagePointer(), itk::testhelper::ImageRegistrationMethodImageSource< TFixedPixelType, TMovingPixelType, VDimension >::GetMovingImage(), itk::HistogramThresholdCalculator< THistogram, TOutput >::MakeOutput(), itk::ImageRegistrationMethodv4< TFixedImage, TMovingImage, TOutputTransform, TVirtualImage, TPointSet >::MakeOutputTransform(), and itk::watershed::BoundaryResolver< TPixelType, TDimension >::SetEquivalencyTable().
|
inlinenoexcept |
Test if the pointer is not NULL.
Definition at line 117 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::BSplineResampleImageFunction< TImageType, TCoordRep >::SetInputImage().
|
inlinenoexcept |
Test if the pointer is NULL.
Definition at line 124 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::SmartPointer< TObjectType >::Print().
|
inlineexplicitnoexcept |
Definition at line 110 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
|
inlinenoexcept |
Return pointer to object.
Definition at line 113 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
|
inlinenoexcept |
Definition at line 108 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
|
inlinenoexcept |
Overload operator ->
Definition at line 106 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
|
inlinenoexcept |
Overload operator assignment.
This method is also implicitly used for move semantics. Additionally, it relies on constructors for additional conversion for pointer types.
Definition at line 154 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::Swap().
|
inlinenoexcept |
Definition at line 164 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer, and itk::SmartPointer< TObjectType >::UnRegister().
|
inline |
Function to print object pointed to
Definition at line 173 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::IsNull(), and itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::operator<<().
|
inlineprivatenoexcept |
Definition at line 212 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::SmartPointer< TObjectType >::SmartPointer().
|
inlinenoexcept |
Definition at line 197 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::SmartPointer< TObjectType >::operator=().
|
inlineprivatenoexcept |
Definition at line 221 of file itkSmartPointer.h.
References itk::SmartPointer< TObjectType >::m_Pointer.
Referenced by itk::SmartPointer< TObjectType >::operator=(), and itk::SmartPointer< TObjectType >::~SmartPointer().
Definition at line 209 of file itkSmartPointer.h.
|
private |
The pointer to the object referred to by this smart pointer.
Definition at line 206 of file itkSmartPointer.h.
Referenced by itk::SmartPointer< TObjectType >::get(), itk::SmartPointer< TObjectType >::GetPointer(), itk::SmartPointer< TObjectType >::IsNotNull(), itk::SmartPointer< TObjectType >::IsNull(), itk::SmartPointer< TObjectType >::operator bool(), itk::SmartPointer< TObjectType >::operator ObjectType *(), itk::SmartPointer< TObjectType >::operator*(), itk::SmartPointer< TObjectType >::operator->(), itk::SmartPointer< TObjectType >::operator=(), itk::SmartPointer< TObjectType >::Print(), itk::SmartPointer< TObjectType >::Register(), itk::SmartPointer< TObjectType >::Swap(), and itk::SmartPointer< TObjectType >::UnRegister().