itk::SmartPointer< TObjectType > Class Template Reference
[ITK System ObjectsData Access Objects]

Implements transparent reference counting. More...

#include <itkSmartPointer.h>

Collaboration diagram for itk::SmartPointer< TObjectType >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef TObjectType ObjectType

Public Member Functions

 SmartPointer ()
 SmartPointer (const SmartPointer< ObjectType > &p)
 SmartPointer (ObjectType *p)
 ~SmartPointer ()
ObjectType * operator-> () const
 operator ObjectType * () const
bool IsNotNull () const
bool IsNull () const
template<typename TR>
bool operator== (TR r) const
template<typename TR>
bool operator!= (TR r) const
ObjectType * GetPointer () const
bool operator< (const SmartPointer &r) const
bool operator> (const SmartPointer &r) const
bool operator<= (const SmartPointer &r) const
bool operator>= (const SmartPointer &r) const
SmartPointeroperator= (const SmartPointer &r)
SmartPointeroperator= (ObjectType *r)
ObjectType * Print (std::ostream &os) const

Private Member Functions

void Register ()
void UnRegister ()

Private Attributes

ObjectType * m_Pointer


Detailed Description

template<class 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; ..exe linux: c++ SmartPointerTest.cxx ./a.out other: CCcompiler SmartPointerTest.cxx ./a.out

Examples:

ChangeDetection/ChangeDetectionFrameworkExample.cxx.

Definition at line 42 of file itkSmartPointer.h.


Constructor & Destructor Documentation

template<class TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer (  )  [inline]

Constructor

Definition at line 48 of file itkSmartPointer.h.

00049     { m_Pointer = 0; }

template<class TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer ( const SmartPointer< ObjectType > &  p  )  [inline]

Copy constructor

Definition at line 52 of file itkSmartPointer.h.

00052                                                   :
00053     m_Pointer(p.m_Pointer)
00054     { this->Register(); }
  

template<class TObjectType>
itk::SmartPointer< TObjectType >::SmartPointer ( ObjectType *  p  )  [inline]

Constructor to pointer p

Definition at line 57 of file itkSmartPointer.h.

00057                               :
00058     m_Pointer(p)
00059     { this->Register(); }
  

template<class TObjectType>
itk::SmartPointer< TObjectType >::~SmartPointer (  )  [inline]

Destructor

Definition at line 62 of file itkSmartPointer.h.

00063     {
00064     this->UnRegister();
00065     m_Pointer = 0;  
00066     }


Member Function Documentation

template<class TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::operator-> (  )  const [inline]

Overload operator ->

Definition at line 69 of file itkSmartPointer.h.

00070     { return m_Pointer; }

template<class TObjectType>
itk::SmartPointer< TObjectType >::operator ObjectType * (  )  const [inline]

Return pointer to object.

Definition at line 73 of file itkSmartPointer.h.

00074     { return m_Pointer; }

template<class TObjectType>
bool itk::SmartPointer< TObjectType >::IsNotNull (  )  const [inline]

Test if the pointer has been initialized

Definition at line 77 of file itkSmartPointer.h.

Referenced by otb::ImageFileReader< TOutputImage >::GenerateOutputInformation(), otb::GlWidget::handle(), and otb::GlWidget::resize().

00078     { return m_Pointer != 0; }

template<class TObjectType>
template<typename TR>
bool itk::SmartPointer< TObjectType >::operator== ( TR  r  )  const [inline]

Template comparison operators.

Definition at line 84 of file itkSmartPointer.h.

00085     { return (m_Pointer == static_cast<const ObjectType*>(r) ); }

template<class TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::GetPointer (  )  const [inline]

Access function to pointer.

Definition at line 92 of file itkSmartPointer.h.

Referenced by otb::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms::AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms(), itk::BayesianClassifierImageFilter< TInputVectorImage, TLabelsType, TPosteriorsPrecisionType, TPriorsPrecisionType >::BayesianClassifierImageFilter(), itk::BinaryMinMaxCurvatureFlowImageFilter< TInputImage, TOutputImage >::BinaryMinMaxCurvatureFlowImageFilter(), itk::Rigid2DTransform< TScalarType >::CloneInverseTo(), itk::CenteredSimilarity2DTransform< TScalarType >::CloneInverseTo(), itk::Euler2DTransform< TScalarType >::CloneInverseTo(), itk::CenteredRigid2DTransform< TScalarType >::CloneInverseTo(), itk::Similarity2DTransform< TScalarType >::CloneInverseTo(), itk::SpatialObjectDuplicator< TInputSpatialObject >::CopyObject(), itk::CoreAtomImageToDistanceMatrixProcess< TSourceImage >::CoreAtomImageToDistanceMatrixProcess(), itk::CoreAtomImageToUnaryCorrespondenceMatrixProcess< TSourceImage >::CoreAtomImageToUnaryCorrespondenceMatrixProcess(), itk::BSplineDeformableTransform< TScalarType, NDimensions, VSplineOrder >::CreateAnother(), itk::Object::CreateAnother(), itk::CreateObjectFunction< T >::CreateObject(), itk::CurvatureFlowImageFilter< TInputImage, TOutputImage >::CurvatureFlowImageFilter(), itk::DemonsRegistrationFilter< TFixedImage, TMovingImage, TDeformationField >::DemonsRegistrationFilter(), itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::DemonsRegistrationFunction(), itk::DiffeomorphicDemonsRegistrationFilter< TFixedImage, TMovingImage, TDeformationField >::DiffeomorphicDemonsRegistrationFilter(), itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::ESMDemonsRegistrationFunction(), itk::ExpandImageFilter< TInputImage, TOutputImage >::ExpandImageFilter(), itk::FastSymmetricForcesDemonsRegistrationFilter< TFixedImage, TMovingImage, TDeformationField >::FastSymmetricForcesDemonsRegistrationFilter(), itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::FastSymmetricForcesDemonsRegistrationFunction(), itk::fem::FEMRegistrationFilter< TMovingImage, TFixedImage >::FEMRegistrationFilter(), itk::ScalarImageKmeansImageFilter< TInputImage, TOutputImage >::GenerateData(), otb::ImageToPathListAlignFilter< TInputImage, TOutputPath >::GenerateData(), otb::GeodesicMorphologyIterativeDecompositionImageFilter< TImage, TStructuringElement >::GeodesicMorphologyIterativeDecompositionImageFilter(), itk::SpatialObjectFactoryBase::GetFactory(), itk::TransformFactoryBase::GetFactory(), itk::fem::Solver::GetInterpolationGrid(), itk::CenteredSimilarity2DTransform< TScalarType >::GetInverseTransform(), itk::CenteredRigid2DTransform< TScalarType >::GetInverseTransform(), itk::Euler2DTransform< TScalarType >::GetInverseTransform(), itk::CenteredEuler3DTransform< TScalarType >::GetInverseTransform(), itk::CenteredAffineTransform< TScalarType, NDimensions >::GetInverseTransform(), itk::Rigid3DTransform< TScalarType >::GetInverseTransform(), itk::Rigid2DTransform< TScalarType >::GetInverseTransform(), itk::Similarity2DTransform< TScalarType >::GetInverseTransform(), itk::ScalableAffineTransform< TScalarType, NDimensions >::GetInverseTransform(), itk::ScaleTransform< TScalarType, NDimensions >::GetInverseTransform(), itk::TranslationTransform< TScalarType, NDimensions >::GetInverseTransform(), itk::MatrixOffsetTransformBase< TScalarType, NInputDimensions, NOutputDimensions >::GetInverseTransform(), itk::AffineTransform< TScalarType, NDimensions >::GetInverseTransform(), otb::FilterWatcherBase::GetProcess(), otb::WriterWatcherBase::GetProcess(), itk::TreeContainer< itk::SpatialObject< TDimension > * >::GetRoot(), itk::ImageRegistrationMethod< TFixedImage, TMovingImage >::ImageRegistrationMethod(), itk::ImageToSpatialObjectRegistrationMethod< TFixedImage, TMovingSpatialObject >::ImageToSpatialObjectRegistrationMethod(), itk::LevelSetMotionRegistrationFilter< TFixedImage, TMovingImage, TDeformationField >::LevelSetMotionRegistrationFilter(), itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::LevelSetMotionRegistrationFunction(), itk::MaskedMovingHistogramImageFilter< TInputImage, TMaskImage, TOutputImage, TKernel, THistogram >::MakeOutput(), itk::EigenAnalysis2DImageFilter< TInputImage, TEigenValueImage, TEigenVectorImage >::MakeOutput(), itk::ProcessObject::MakeOutput(), itk::Statistics::ImageToListGenerator< TImage, TMaskImage >::MakeOutput(), itk::watershed::BoundaryResolver< TPixelType, TDimension >::MakeOutput(), itk::watershed::Segmenter< TInputImage >::MakeOutput(), itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::MeanSquareRegistrationFunction(), itk::MedialNodePairCorrespondenceProcess< TSourceImage >::MedialNodePairCorrespondenceProcess(), itk::MedialNodeTripletCorrespondenceProcess< TSourceImage >::MedialNodeTripletCorrespondenceProcess(), itk::MinMaxCurvatureFlowImageFilter< TInputImage, TOutputImage >::MinMaxCurvatureFlowImageFilter(), itk::MIRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::MIRegistrationFunction(), otb::MorphologicalPyramidAnalysisFilter< TInputImage, TOutputImage, TMorphoFilter >::MorphologicalPyramidAnalysisFilter(), otb::MorphologicalPyramid::MRToMSConverter< TInputImage, TOutputImage >::MRToMSConverter(), itk::MultiResolutionImageRegistrationMethod< TFixedImage, TMovingImage >::MultiResolutionImageRegistrationMethod(), itk::MultiResolutionPDEDeformableRegistration< TFixedImage, TMovingImage, TDeformationField, TRealType >::MultiResolutionPDEDeformableRegistration(), itk::MultiScaleHessianBasedMeasureImageFilter< TInputImage, THessianImage, TOutputImage >::MultiScaleHessianBasedMeasureImageFilter(), itk::ImageToImageMetric< TFixedImage, TMovingImage >::MultiThreadingInitialize(), itk::MutualInformationImageToImageMetric< TFixedImage, TMovingImage >::MutualInformationImageToImageMetric(), itk::NCCRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::NCCRegistrationFunction(), itk::FFTRealToComplexConjugateImageFilter< TPixel, VDimension >::New(), itk::SmartPointer< itk::Statistics::ImageToListAdaptor >::operator=(), itk::PointSetToImageRegistrationMethod< TFixedPointSet, TMovingImage >::PointSetToImageRegistrationMethod(), itk::PointSetToPointSetRegistrationMethod< TFixedPointSet, TMovingPointSet >::PointSetToPointSetRegistrationMethod(), otb::ObjectList< TObject >::PrintSelf(), itk::watershed::BoundaryResolver< TPixelType, TDimension >::SetEquivalencyTable(), itk::MultiResolutionPyramidImageFilter< TInputImage, TOutputImage >::SetNumberOfLevels(), itk::ImagePCAShapeModelEstimator< TInputImage, TOutputImage >::SetNumberOfPrincipalComponentsRequired(), itk::SymmetricForcesDemonsRegistrationFilter< TFixedImage, TMovingImage, TDeformationField >::SymmetricForcesDemonsRegistrationFilter(), itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDeformationField >::SymmetricForcesDemonsRegistrationFunction(), itk::NeuralNetworkFileReader< TNetwork >::Update(), itk::SpatialObjectDuplicator< TInputSpatialObject >::Update(), itk::TransformFileReader::Update(), itk::VectorExpandImageFilter< TInputImage, TOutputImage >::VectorExpandImageFilter(), itk::WarpImageFilter< TInputImage, TOutputImage, TDeformationField >::WarpImageFilter(), and itk::WarpVectorImageFilter< TInputImage, TOutputImage, TDeformationField >::WarpVectorImageFilter().

00093     { return m_Pointer; }

template<class TObjectType>
bool itk::SmartPointer< TObjectType >::operator< ( const SmartPointer< TObjectType > &  r  )  const [inline]

Comparison of pointers. Less than comparison.

Definition at line 96 of file itkSmartPointer.h.

00097     { return (void*)m_Pointer < (void*) r.m_Pointer; }

template<class TObjectType>
bool itk::SmartPointer< TObjectType >::operator> ( const SmartPointer< TObjectType > &  r  )  const [inline]

Comparison of pointers. Greater than comparison.

Definition at line 100 of file itkSmartPointer.h.

00101     { return (void*)m_Pointer > (void*) r.m_Pointer; }

template<class TObjectType>
bool itk::SmartPointer< TObjectType >::operator<= ( const SmartPointer< TObjectType > &  r  )  const [inline]

Comparison of pointers. Less than or equal to comparison.

Definition at line 104 of file itkSmartPointer.h.

00105     { return (void*)m_Pointer <= (void*) r.m_Pointer; }

template<class TObjectType>
bool itk::SmartPointer< TObjectType >::operator>= ( const SmartPointer< TObjectType > &  r  )  const [inline]

Comparison of pointers. Greater than or equal to comparison.

Definition at line 108 of file itkSmartPointer.h.

00109     { return (void*)m_Pointer >= (void*) r.m_Pointer; }

template<class TObjectType>
SmartPointer& itk::SmartPointer< TObjectType >::operator= ( const SmartPointer< TObjectType > &  r  )  [inline]

Overload operator assignment.

Definition at line 112 of file itkSmartPointer.h.

Referenced by itk::SmartPointer< itk::Statistics::ImageToListAdaptor >::operator=().

00113     { return this->operator = (r.GetPointer()); }

template<class TObjectType>
SmartPointer& itk::SmartPointer< TObjectType >::operator= ( ObjectType *  r  )  [inline]

Overload operator assignment.

Definition at line 116 of file itkSmartPointer.h.

00117     {
00118     if (m_Pointer != r)
00119       {
00120       ObjectType* tmp = m_Pointer; //avoid recursive unregisters by retaining temporarily
00121       m_Pointer = r;
00122       this->Register();
00123       if ( tmp ) { tmp->UnRegister(); }
00124       }
00125     return *this;
00126     }

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

Function to print object pointed to

Definition at line 129 of file itkSmartPointer.h.

Referenced by itk::KernelTransform< TScalarType, NDimensions >::PrintSelf().

00130     { 
00131     // This prints the object pointed to by the pointer  
00132     (*m_Pointer).Print(os);  
00133     return m_Pointer;
00134     } 


Member Data Documentation

template<class TObjectType>
ObjectType* itk::SmartPointer< TObjectType >::m_Pointer [private]


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

Generated at Wed Jul 14 07:54:01 2010 for OTB with doxygen 1.5.6