fw4spl
vtkLambdaCommand.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWVTKIO_HELPER_VTKLAMBDACOMMAND_HPP__
8 #define __FWVTKIO_HELPER_VTKLAMBDACOMMAND_HPP__
9 
10 #include "fwVtkIO/config.hpp"
11 
12 #include <vtkCommand.h>
13 
14 #include <functional>
15 
16 namespace fwVtkIO
17 {
18 
19 namespace helper
20 {
21 
25 class FWVTKIO_CLASS_API vtkLambdaCommand : public vtkCommand
26 {
27 public:
28  typedef std::function< void (vtkObject*, unsigned long, void*) > Callback;
29 
31 
32 
35  static vtkLambdaCommand *New()
36  {
37  return new vtkLambdaCommand;
38  }
39 
43  FWVTKIO_API virtual void Execute(vtkObject* caller, unsigned long eid, void* callData) override;
44 
48  virtual void SetCallback(Callback callback)
49  {
50  this->m_callback = callback;
51  }
52 
53 protected:
54 
56  {
57  }
59  {
60  }
61 
62  Callback m_callback;
63 };
64 
65 } // namespace helper
66 } // namespace fwVtkIO
67 
68 #endif // __FWVTKIO_HELPER_VTKLAMBDACOMMAND_HPP__
Allows use of vtkCommand with lambdas.
vtkTypeMacro(vtkLambdaCommand, vtkCommand) static vtkLambdaCommand *New()
returns a new vtkLambdaCommand
virtual void SetCallback(Callback callback)
Sets callback.