SimpleITK  
sitkFunctionCommand.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 sitkFunctionCommand_h
19 #define sitkFunctionCommand_h
20 
21 
22 #include "sitkCommand.h"
23 
24 #include <functional>
25 
26 namespace itk::simple {
27 
33  public Command
34 {
35 public:
36 
38 
39 
40  ~FunctionCommand() override;
41 
43 
44  void Execute() override;
45 
49  template <class T>
50  void SetCallbackFunction ( T *object, void(T::* pMemberFunction )() )
51  {
52  m_Function = [object, pMemberFunction] { std::invoke(pMemberFunction, object); };
53  }
54 
56  void SetCallbackFunction ( void(* pFunction )() );
57 
63  void SetCallbackFunction( void(* pFunction )(void *), void *clientData );
64 
66  void SetCallbackFunction( const std::function<void()> &);
67 
68 private:
69 
70  using FunctionObjectType = std::function<void()>;
72 
73 };
74 
75 }
76 
77 #endif
itk::simple::FunctionCommand::FunctionObjectType
std::function< void()> FunctionObjectType
Definition: sitkFunctionCommand.h:70
itk::simple::FunctionCommand::m_Function
FunctionObjectType m_Function
Definition: sitkFunctionCommand.h:71
itk::simple::Command
An implementation of the Command design pattern for callback.
Definition: sitkCommand.h:43
itk::simple::FunctionCommand::SetCallbackFunction
void SetCallbackFunction(T *object, void(T::*pMemberFunction)())
Definition: sitkFunctionCommand.h:50
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::FunctionCommand
A Command class which allows setting an external function, or member function.
Definition: sitkFunctionCommand.h:32
itk::simple
Definition: sitkAdditionalProcedures.h:28
sitkCommand.h