SimpleITK  1.0.1
sitkFunctionCommand.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
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 "nsstd/functional.h"
25 
26 namespace itk {
27 namespace simple {
28 
34  public Command
35 {
36 public:
37 
39 
41 
42  virtual void Execute(void);
43 
47  template <class T>
48  void SetCallbackFunction ( T *object, void(T::* pMemberFunction )() )
49  {
50  m_Function = nsstd::bind(pMemberFunction, object);
51  }
52 
54  void SetCallbackFunction ( void(* pFunction )() );
55 
61  void SetCallbackFunction( void(* pFunction )(void *), void *clientData );
62 
63 private:
64 
65  typedef nsstd::function<void()> FunctionObjectType;
66  FunctionObjectType m_Function;
67 
68 };
69 
70 } // end namespace simple
71 } // end namespace itk
72 
73 #endif
nsstd::function< void()> FunctionObjectType
A Command class which allows setting an external function, or member function.
An implementation of the Command design pattern for callback.
Definition: sitkCommand.h:44
void SetCallbackFunction(T *object, void(T::*pMemberFunction)())
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41