SimpleITK  1.0.1
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 >:

Public Types

typedef Superclass::FunctionObjectType FunctionObjectType
 
typedef TMemberFunctionPointer MemberFunctionType
 
typedef ::detail::FunctionTraits< MemberFunctionType >::ClassType ObjectType
 
typedef MemberFunctionFactory Self
 
typedef MemberFunctionFactoryBase< TMemberFunctionPointer, int > Superclass
 

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 throw ()
 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 (void)
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 
template<typename TPixelIDTypeList , unsigned int VImageDimension>
void RegisterMemberFunctions (void)
 Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::Image<Pixel, ImageDimension> More...
 

Protected Attributes

ObjectTypem_ObjectPointer
 

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:

typedef Self& (Self::*MemberFunctionType)( Image* );

The RegisterMemberFunctions instantiate the templeted 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 55 of file sitkMemberFunctionFactory.h.

Member Typedef Documentation

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

Definition at line 66 of file sitkMemberFunctionFactory.h.

template<typename TMemberFunctionPointer>
typedef TMemberFunctionPointer itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::MemberFunctionType

Definition at line 64 of file sitkMemberFunctionFactory.h.

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

Definition at line 65 of file sitkMemberFunctionFactory.h.

template<typename TMemberFunctionPointer>
typedef MemberFunctionFactory itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::Self

Definition at line 62 of file sitkMemberFunctionFactory.h.

template<typename TMemberFunctionPointer>
typedef MemberFunctionFactoryBase<TMemberFunctionPointer, int> itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::Superclass

Definition at line 61 of file sitkMemberFunctionFactory.h.

Constructor & Destructor Documentation

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

Constructor which permanently binds the constructed object to pObject.

Member Function Documentation

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 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.

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

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

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

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

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
{
typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
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 > ();
template<typename TMemberFunctionPointer>
template<typename TPixelIDTypeList , unsigned int VImageDimension>
void itk::simple::detail::MemberFunctionFactory< TMemberFunctionPointer >::RegisterMemberFunctions ( void  )
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
{
typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType ObjectType;
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 > ();

Definition at line 120 of file sitkMemberFunctionFactory.h.

Member Data Documentation

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

Definition at line 155 of file sitkMemberFunctionFactory.h.


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