fw4spl
FuncSlot.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 __FWGUIQT_UTIL_FUNCSLOT_HPP__
8 #define __FWGUIQT_UTIL_FUNCSLOT_HPP__
9 
10 #include <fwGuiQt/config.hpp>
11 
12 #include <QObject>
13 
14 #include <functional>
15 
16 namespace fwGuiQt
17 {
18 
19 namespace util
20 {
21 
22 class FWGUIQT_CLASS_API FuncSlot : public QObject
23 {
24 Q_OBJECT
25 
26 public:
27  FWGUIQT_API FuncSlot();
28 
29  template< typename CALLABLE >
30  FuncSlot(CALLABLE c) :
31  m_func(c)
32  {
33  }
34 
35  //------------------------------------------------------------------------------
36 
37  template< typename CALLABLE >
38  void setFunction(CALLABLE c)
39  {
40  m_func = c;
41  }
42 
43 public Q_SLOTS:
44  void trigger();
45 
46 protected:
47  std::function< void() > m_func;
48 };
49 
50 } // namespace util
51 
52 } // namespace fwGuiQt
53 
54 #endif //__FWGUIQT_UTIL_FUNCSLOT_HPP__
55 
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
Definition: WindowLevel.hpp:32