SimpleITK  
Public Types | Public Member Functions | Protected Attributes | List of all members
itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer > Class Template Reference

A class used to instantiate and generate function object to templated member functions. More...

#include <sitkMemberFunctionFactory.h>

+ Inheritance diagram for itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >:
+ Collaboration diagram for itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >:

Detailed Description

template<typename TMemberFunctionPointer>
class itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >

A class used to instantiate and generate function object to templated member functions.

Template Parameters
TMemberFunctionPointeris the type of pointer to member function

Example member function pointer:

type alias Self& (Self::*MemberFunctionType)( Image* );

The RegisterMemberFunctions instantiate the templated member functions and registers the member function pointer, so that it be used for dispatch later. Later they can be retrieve with the GetMemberFunction methods, which return a function object with the same arguments as the templated member function pointer.

An instance of a MemberFunctionFactory is bound to a specific instance of an object, so that the returned function object does not need to have the calling object specified.

Definition at line 51 of file sitkMemberFunctionFactory.h.

Public Types

using FunctionObjectType = typename Superclass::FunctionObjectType
 
using MemberFunctionType = TMemberFunctionPointer
 
using ObjectType = typename ::detail::FunctionTraits< MemberFunctionType >::ClassType
 
using Self = MemberFunctionFactory
 
using Superclass = MemberFunctionFactoryBase< TMemberFunctionPointer, std::pair< unsigned int, int > >
 

Public Member Functions

FunctionObjectType GetMemberFunction (PixelIDValueType pixelID, unsigned int imageDimension)
 Returns a function object for the PixelIndex, and image dimension. More...
 
bool HasMemberFunction (PixelIDValueType pixelID, unsigned int imageDimension) const noexcept
 Query to determine if an member function has been registered for pixelID and imageDimension. More...
 
 MemberFunctionFactory (ObjectType *pObject)
 Constructor which permanently binds the constructed object to pObject. More...
 
template<typename TImageType >
void Register (MemberFunctionType pfunc, TImageType *)
 Registers a specific member function. More...
 
template<typename TPixelIDTypeList , unsigned int VImageDimension, typename TAddressor >
void RegisterMemberFunctions ()
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 
template<typename TPixelIDTypeList , unsigned int VImageDimension>
void RegisterMemberFunctions ()
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 
template<typename TPixelIDTypeList , unsigned int VImageDimension, unsigned int VImageDimensionStop>
void RegisterMemberFunctions ()
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 
template<typename TPixelIDTypeList , unsigned int VImageDimension, unsigned int VImageDimensionStop, typename TAddressor >
void RegisterMemberFunctions ()
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 

Protected Attributes

ObjectTypem_ObjectPointer
 
- Protected Attributes inherited from itk::simple::detail::MemberFunctionFactoryBase< TMemberFunctionPointer, std::pair< unsigned int, int > >
FunctionMapType m_PFunction
 

Additional Inherited Members

- Protected Types inherited from itk::simple::detail::MemberFunctionFactoryBase< TMemberFunctionPointer, std::pair< unsigned int, int > >
using FunctionMapType = std::unordered_map< std::pair< unsigned int, int >, FunctionObjectType, hash< std::pair< unsigned int, int > > >
 
using KeyType = std::pair< unsigned int, int >
 
using MemberFunctionResultType = typename ::detail::FunctionTraits< MemberFunctionType >::ResultType
 
using MemberFunctionType = TMemberFunctionPointer
 
using ObjectType = typename ::detail::FunctionTraits< MemberFunctionType >::ClassType
 
using FunctionObjectType = typename ::detail::FunctionTraits< MemberFunctionType >::FunctionObjectType
 
- Protected Member Functions inherited from itk::simple::detail::MemberFunctionFactoryBase< TMemberFunctionPointer, std::pair< unsigned int, int > >
 MemberFunctionFactoryBase ()
 
- Static Protected Member Functions inherited from itk::simple::detail::MemberFunctionFactoryBase< TMemberFunctionPointer, std::pair< unsigned int, int > >
static FunctionObjectType BindObject (MemberFunctionResultType(ObjectType ::*pfunc)(Args...), ObjectType *objectPointer)
 

Member Typedef Documentation

◆ FunctionObjectType

template<typename TMemberFunctionPointer >
using itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::FunctionObjectType = typename Superclass::FunctionObjectType

Definition at line 60 of file sitkMemberFunctionFactory.h.

◆ MemberFunctionType

template<typename TMemberFunctionPointer >
using itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::MemberFunctionType = TMemberFunctionPointer

Definition at line 58 of file sitkMemberFunctionFactory.h.

◆ ObjectType

template<typename TMemberFunctionPointer >
using itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::ObjectType = typename ::detail::FunctionTraits<MemberFunctionType>::ClassType

Definition at line 59 of file sitkMemberFunctionFactory.h.

◆ Self

template<typename TMemberFunctionPointer >
using itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::Self = MemberFunctionFactory

Definition at line 56 of file sitkMemberFunctionFactory.h.

◆ Superclass

template<typename TMemberFunctionPointer >
using itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::Superclass = MemberFunctionFactoryBase<TMemberFunctionPointer, std::pair<unsigned int, int> >

Definition at line 55 of file sitkMemberFunctionFactory.h.

Constructor & Destructor Documentation

◆ MemberFunctionFactory()

template<typename TMemberFunctionPointer >
itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::MemberFunctionFactory ( ObjectType pObject)

Constructor which permanently binds the constructed object to pObject.

Member Function Documentation

◆ GetMemberFunction()

template<typename TMemberFunctionPointer >
FunctionObjectType itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::GetMemberFunction ( PixelIDValueType  pixelID,
unsigned int  imageDimension 
)

Returns a function object for the PixelIndex, and image dimension.

pixelID is the value of Image::GetPixelIDValue(), or PixelIDToPixelIDValue<PixelIDType>::Result

imageDimension is the value returned by Image::GetDimension()

Example usage:

PixelIDValueType pixelID = image->GetPixelIDValue();
unsigned int dimension = image->GetDimension();
return this->m_MemberFactory->GetMemberFunction( pixelID, dimension )( image );

If the requested member function is not registered then an exception is generated. The returned function object is guaranteed to be valid.

◆ HasMemberFunction()

template<typename TMemberFunctionPointer >
bool itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::HasMemberFunction ( PixelIDValueType  pixelID,
unsigned int  imageDimension 
) const
noexcept

Query to determine if an member function has been registered for pixelID and imageDimension.

◆ Register()

template<typename TMemberFunctionPointer >
template<typename TImageType >
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::Register ( MemberFunctionType  pfunc,
TImageType *   
)

Registers a specific member function.

Registers a member function which will be dispatched to the TImageType type

◆ RegisterMemberFunctions() [1/4]

template<typename TMemberFunctionPointer >
template<typename TPixelIDTypeList , unsigned int VImageDimension, typename TAddressor >
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::RegisterMemberFunctions ( )

Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension>

Template Parameters
TAddressoris the type of a class who as a templated operator() which returns TMemberFunctionPointer, this will default to detail::MemberFunctionAddressor if not specified

Example usage:

template < class TMemberFunctionPointer >
struct AllocateAddressor
{
using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
template< typename TImageType >
TMemberFunctionPointer operator() ( void ) const
{
return &ObjectType::template AllocateInternal< TImageType >;
}
};
this->m_MemberFunctionFactory->RegisterMemberFunctions<PixelIDTypeList,
3,
AllocateAddressor<TMFP> > ();

Example usage:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 3 > ();
this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2 > ();

A range can also be used:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2, 3 > ();

Referenced by itk::simple::detail::MemberFunctionFactory< MemberFunctionType >::RegisterMemberFunctions().

◆ RegisterMemberFunctions() [2/4]

template<typename TMemberFunctionPointer >
template<typename TPixelIDTypeList , unsigned int VImageDimension>
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::RegisterMemberFunctions ( )
inline

Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension>

Template Parameters
TAddressoris the type of a class who as a templated operator() which returns TMemberFunctionPointer, this will default to detail::MemberFunctionAddressor if not specified

Example usage:

template < class TMemberFunctionPointer >
struct AllocateAddressor
{
using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
template< typename TImageType >
TMemberFunctionPointer operator() ( void ) const
{
return &ObjectType::template AllocateInternal< TImageType >;
}
};
this->m_MemberFunctionFactory->RegisterMemberFunctions<PixelIDTypeList,
3,
AllocateAddressor<TMFP> > ();

Example usage:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 3 > ();
this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2 > ();

A range can also be used:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2, 3 > ();

Definition at line 120 of file sitkMemberFunctionFactory.h.

◆ RegisterMemberFunctions() [3/4]

template<typename TMemberFunctionPointer >
template<typename TPixelIDTypeList , unsigned int VImageDimension, unsigned int VImageDimensionStop>
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::RegisterMemberFunctions ( )
inline

Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension>

Template Parameters
TAddressoris the type of a class who as a templated operator() which returns TMemberFunctionPointer, this will default to detail::MemberFunctionAddressor if not specified

Example usage:

template < class TMemberFunctionPointer >
struct AllocateAddressor
{
using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
template< typename TImageType >
TMemberFunctionPointer operator() ( void ) const
{
return &ObjectType::template AllocateInternal< TImageType >;
}
};
this->m_MemberFunctionFactory->RegisterMemberFunctions<PixelIDTypeList,
3,
AllocateAddressor<TMFP> > ();

Example usage:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 3 > ();
this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2 > ();

A range can also be used:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2, 3 > ();

Definition at line 128 of file sitkMemberFunctionFactory.h.

◆ RegisterMemberFunctions() [4/4]

template<typename TMemberFunctionPointer >
template<typename TPixelIDTypeList , unsigned int VImageDimension, unsigned int VImageDimensionStop, typename TAddressor >
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::RegisterMemberFunctions ( )
inline

Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension>

Template Parameters
TAddressoris the type of a class who as a templated operator() which returns TMemberFunctionPointer, this will default to detail::MemberFunctionAddressor if not specified

Example usage:

template < class TMemberFunctionPointer >
struct AllocateAddressor
{
using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
template< typename TImageType >
TMemberFunctionPointer operator() ( void ) const
{
return &ObjectType::template AllocateInternal< TImageType >;
}
};
this->m_MemberFunctionFactory->RegisterMemberFunctions<PixelIDTypeList,
3,
AllocateAddressor<TMFP> > ();

Example usage:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 3 > ();
this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2 > ();

A range can also be used:

this->m_MemberFactory->RegisterMemberFunctions< PixelIDTypeList, 2, 3 > ();

Definition at line 138 of file sitkMemberFunctionFactory.h.

Member Data Documentation

◆ m_ObjectPointer

template<typename TMemberFunctionPointer >
ObjectType* itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::m_ObjectPointer
protected

Definition at line 177 of file sitkMemberFunctionFactory.h.


The documentation for this class was generated from the following file:
itk::simple::detail::MemberFunctionFactory::Self
MemberFunctionFactory Self
Definition: sitkMemberFunctionFactory.h:56
itk::simple::detail::MemberFunctionFactory::MemberFunctionType
TMemberFunctionPointer MemberFunctionType
Definition: sitkMemberFunctionFactory.h:58
itk::simple::detail::MemberFunctionFactory::ObjectType
typename ::detail::FunctionTraits< MemberFunctionType >::ClassType ObjectType
Definition: sitkMemberFunctionFactory.h:59
AddImageFilter
itk::simple::PixelIDValueType
int PixelIDValueType
Definition: sitkPixelIDValues.h:30