SimpleITK  
sitkMemberFunctionFactory.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 #ifndef sitkMemberFunctionFactory_h
19 #define sitkMemberFunctionFactory_h
20 
21 #include "sitkDetail.h"
23 #include "sitkPixelIDValues.h"
24 
25 namespace itk::simple::detail {
26 
49 template <typename TMemberFunctionPointer>
51  : protected MemberFunctionFactoryBase<TMemberFunctionPointer, std::pair<unsigned int, int> >
52 {
53 
54 public:
55 
58 
59  using MemberFunctionType = TMemberFunctionPointer;
60  using ObjectType = typename ::detail::FunctionTraits<MemberFunctionType>::ClassType;
61  using FunctionObjectType = typename Superclass::FunctionObjectType;
62 
66 
72  template< typename TImageType >
73  void Register( MemberFunctionType pfunc, TImageType* );
74 
115  template < typename TPixelIDTypeList,
116  unsigned int VImageDimension,
117  typename TAddressor >
118  void RegisterMemberFunctions( );
119  template < typename TPixelIDTypeList, unsigned int VImageDimension >
121  {
123  this->RegisterMemberFunctions< TPixelIDTypeList, VImageDimension, AddressorType >();
124  }
125 
126  template < typename TPixelIDTypeList, unsigned int VImageDimension, unsigned int VImageDimensionStop >
127  void
129  {
131  this->RegisterMemberFunctions< TPixelIDTypeList, VImageDimension, VImageDimensionStop, AddressorType >();
132  }
133  template < typename TPixelIDTypeList,
134  unsigned int VImageDimension,
135  unsigned int VImageDimensionStop,
136  typename TAddressor
137  >
138  typename std::enable_if<(VImageDimensionStop > VImageDimension)>::type
140  {
141  this->RegisterMemberFunctions< TPixelIDTypeList, VImageDimensionStop, TAddressor >();
142  this->RegisterMemberFunctions< TPixelIDTypeList, VImageDimension, VImageDimensionStop - 1, TAddressor >();
143  }
144  template < typename TPixelIDTypeList,
145  unsigned int VImageDimension,
146  unsigned int VImageDimensionStop,
147  typename TAddressor >
148  typename std::enable_if<(VImageDimensionStop == VImageDimension)>::type
150  {
151  this->RegisterMemberFunctions< TPixelIDTypeList, VImageDimensionStop, TAddressor >();
152  }
158  bool HasMemberFunction( PixelIDValueType pixelID, unsigned int imageDimension ) const noexcept;
159 
179  FunctionObjectType GetMemberFunction( PixelIDValueType pixelID, unsigned int imageDimension );
180 
181 protected:
182 
184 
185 };
186 
187 }
188 
189 #include "sitkMemberFunctionFactory.hxx"
190 
191 #endif // sitkMemberFunctionFactory_h
itk::simple::detail::MemberFunctionFactory< MemberFunctionType >::FunctionObjectType
typename Superclass::FunctionObjectType FunctionObjectType
Definition: sitkMemberFunctionFactory.h:61
itk::simple::detail::MemberFunctionFactory::Register
void Register(MemberFunctionType pfunc, TImageType *)
Registers a specific member function.
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:28
itk::simple::detail::MemberFunctionFactory::GetMemberFunction
FunctionObjectType GetMemberFunction(PixelIDValueType pixelID, unsigned int imageDimension)
Returns a function object for the PixelIndex, and image dimension.
itk::simple::detail::MemberFunctionFactory< MemberFunctionType >::MemberFunctionType
MemberFunctionType MemberFunctionType
Definition: sitkMemberFunctionFactory.h:59
itk::simple::detail::MemberFunctionFactory
A class used to instantiate and generate function object to templated member functions.
Definition: sitkMemberFunctionFactory.h:50
itk::simple::detail
Definition: sitkDetail.h:24
itk::simple::detail::MemberFunctionFactory::RegisterMemberFunctions
void RegisterMemberFunctions()
Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::...
Definition: sitkMemberFunctionFactory.h:120
sitkDetail.h
sitkMemberFunctionFactoryBase.h
itk::simple::detail::MemberFunctionFactory::HasMemberFunction
bool HasMemberFunction(PixelIDValueType pixelID, unsigned int imageDimension) const noexcept
Query to determine if an member function has been registered for pixelID and imageDimension.
sitkPixelIDValues.h
itk::simple::detail::MemberFunctionFactory::ObjectType
typename ::detail::FunctionTraits< MemberFunctionType >::ClassType ObjectType
Definition: sitkMemberFunctionFactory.h:60
itk::simple::detail::MemberFunctionFactory::m_ObjectPointer
ObjectType * m_ObjectPointer
Definition: sitkMemberFunctionFactory.h:183
itk::simple::detail::MemberFunctionFactory::RegisterMemberFunctions
void RegisterMemberFunctions()
Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::...
itk::simple::detail::MemberFunctionFactory::RegisterMemberFunctions
std::enable_if<(VImageDimensionStop==VImageDimension)>::type RegisterMemberFunctions()
Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::...
Definition: sitkMemberFunctionFactory.h:149
itk::simple::detail::MemberFunctionFactory::RegisterMemberFunctions
std::enable_if<(VImageDimensionStop > VImageDimension)>::type RegisterMemberFunctions()
Registers all member functions in TPixelIDTypeList and simple::InstantiatedPixelIDTypeList over itk::...
Definition: sitkMemberFunctionFactory.h:139
itk::simple::PixelIDValueType
int PixelIDValueType
Definition: sitkPixelIDValues.h:30
itk::simple::detail::MemberFunctionFactory::MemberFunctionFactory
MemberFunctionFactory(ObjectType *pObject)
Constructor which permanently binds the constructed object to pObject.
itk::simple::detail::MemberFunctionFactoryBase
A base class for the MemberFunctionFactory.
Definition: sitkMemberFunctionFactoryBase.h:96