ITK  5.0.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
itk::SmartPointer< TObjectType > Class Template Reference

#include <itkSmartPointer.h>

+ Inheritance diagram for itk::SmartPointer< TObjectType >:

Detailed Description

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

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.

Examples:
Examples/RegistrationITKv3/DeformableRegistration10.cxx, Examples/RegistrationITKv3/DeformableRegistration2.cxx, Examples/RegistrationITKv3/DeformableRegistration3.cxx, Examples/RegistrationITKv3/DeformableRegistration5.cxx, Examples/RegistrationITKv3/DeformableRegistration9.cxx, Examples/RegistrationITKv4/DeformableRegistration10.cxx, Examples/RegistrationITKv4/DeformableRegistration2.cxx, Examples/RegistrationITKv4/DeformableRegistration3.cxx, Examples/RegistrationITKv4/DeformableRegistration5.cxx, and Examples/RegistrationITKv4/DeformableRegistration9.cxx.

Definition at line 51 of file itkSmartPointer.h.

Public Types

template<typename T >
using EnableIfConvertible = typename std::enable_if< std::is_convertible< T *, TObjectType * >::value >
 
using ObjectType = TObjectType
 

Public Member Functions

ObjectTypeGetPointer () const noexcept
 
bool IsNotNull () const noexcept
 
bool IsNull () const noexcept
 
 operator bool () const noexcept
 
 operator ObjectType * () const noexcept
 
ObjectTypeoperator* () const noexcept
 
ObjectTypeoperator-> () const noexcept
 
SmartPointeroperator= (std::nullptr_t) noexcept
 
constexpr SmartPointer () noexcept
 
 SmartPointer (const SmartPointer &p) noexcept
 
constexpr SmartPointer (std::nullptr_t p) noexcept
 
template<typename T , typename = typename EnableIfConvertible<T>::type>
 SmartPointer (const SmartPointer< T > &p) noexcept
 
 SmartPointer (SmartPointer< ObjectType > &&p) noexcept
 
template<typename T , typename = typename EnableIfConvertible<T>::type>
 SmartPointer (SmartPointer< T > &&p) noexcept
 
 SmartPointer (ObjectType *p) noexcept
 
void Swap (SmartPointer &other) noexcept
 
 ~SmartPointer ()
 
SmartPointeroperator= (SmartPointer r) noexcept
 
ObjectTypePrint (std::ostream &os) const
 

Private Member Functions

void Register () noexcept
 
void UnRegister () noexcept
 

Private Attributes

ObjectTypem_Pointer
 

Friends

template<typename T >
class SmartPointer
 

Member Typedef Documentation

template<typename TObjectType>
template<typename T >
using itk::SmartPointer< TObjectType >::EnableIfConvertible = typename std::enable_if<std::is_convertible<T*, TObjectType*>::value>

Definition at line 57 of file itkSmartPointer.h.

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

Definition at line 54 of file itkSmartPointer.h.

Constructor & Destructor Documentation

template<typename TObjectType>
constexpr itk::SmartPointer< TObjectType >::SmartPointer ( )
inlinenoexcept

Constructor

Definition at line 60 of file itkSmartPointer.h.

template<typename TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer ( const SmartPointer< TObjectType > &  p)
inlinenoexcept

Copy constructor

Definition at line 65 of file itkSmartPointer.h.

template<typename TObjectType>
constexpr itk::SmartPointer< TObjectType >::SmartPointer ( std::nullptr_t  p)
inlinenoexcept

Definition at line 69 of file itkSmartPointer.h.

template<typename TObjectType>
template<typename T , typename = typename EnableIfConvertible<T>::type>
itk::SmartPointer< TObjectType >::SmartPointer ( const SmartPointer< T > &  p)
inlinenoexcept

constructor with implicit conversion of pointer type

Definition at line 76 of file itkSmartPointer.h.

template<typename TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer ( SmartPointer< ObjectType > &&  p)
inlinenoexcept

Move constructor

Definition at line 83 of file itkSmartPointer.h.

template<typename TObjectType>
template<typename T , typename = typename EnableIfConvertible<T>::type>
itk::SmartPointer< TObjectType >::SmartPointer ( SmartPointer< T > &&  p)
inlinenoexcept

move constructor with implicit conversion of pointer type

Definition at line 90 of file itkSmartPointer.h.

template<typename TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer ( ObjectType p)
inlinenoexcept

Constructor to pointer p

Definition at line 95 of file itkSmartPointer.h.

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

Destructor

Definition at line 100 of file itkSmartPointer.h.

Member Function Documentation

template<typename TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::GetPointer ( ) const
inlinenoexcept
template<typename TObjectType>
bool itk::SmartPointer< TObjectType >::IsNotNull ( ) const
inlinenoexcept
template<typename TObjectType>
bool itk::SmartPointer< TObjectType >::IsNull ( ) const
inlinenoexcept

Test if the pointer is NULL.

Definition at line 126 of file itkSmartPointer.h.

Referenced by itk::SmartPointer< const Self >::Print().

template<typename TObjectType>
itk::SmartPointer< TObjectType >::operator bool ( ) const
inlineexplicitnoexcept

Definition at line 114 of file itkSmartPointer.h.

template<typename TObjectType>
itk::SmartPointer< TObjectType >::operator ObjectType * ( ) const
inlinenoexcept

Return pointer to object.

Definition at line 118 of file itkSmartPointer.h.

template<typename TObjectType>
ObjectType& itk::SmartPointer< TObjectType >::operator* ( ) const
inlinenoexcept

Definition at line 111 of file itkSmartPointer.h.

template<typename TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::operator-> ( ) const
inlinenoexcept

Overload operator ->

Definition at line 108 of file itkSmartPointer.h.

template<typename TObjectType>
SmartPointer& itk::SmartPointer< TObjectType >::operator= ( SmartPointer< TObjectType >  r)
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 141 of file itkSmartPointer.h.

template<typename TObjectType>
SmartPointer& itk::SmartPointer< TObjectType >::operator= ( std::nullptr_t  )
inlinenoexcept

Definition at line 151 of file itkSmartPointer.h.

template<typename TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::Print ( std::ostream &  os) const
inline

Function to print object pointed to

Definition at line 159 of file itkSmartPointer.h.

template<typename TObjectType>
void itk::SmartPointer< TObjectType >::Register ( )
inlineprivatenoexcept

Definition at line 195 of file itkSmartPointer.h.

Referenced by itk::SmartPointer< const Self >::SmartPointer().

template<typename TObjectType>
void itk::SmartPointer< TObjectType >::Swap ( SmartPointer< TObjectType > &  other)
inlinenoexcept

Definition at line 181 of file itkSmartPointer.h.

Referenced by itk::SmartPointer< const Self >::operator=().

template<typename TObjectType>
void itk::SmartPointer< TObjectType >::UnRegister ( )
inlineprivatenoexcept

Friends And Related Function Documentation

template<typename TObjectType>
template<typename T >
friend class SmartPointer
friend

Definition at line 193 of file itkSmartPointer.h.

Member Data Documentation

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

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