fw4spl
SlotRun.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 #ifndef __FWCOM_SLOTRUN_HPP__
7 #define __FWCOM_SLOTRUN_HPP__
8 
9 #include "fwCom/SlotBase.hpp"
10 
11 #include <functional>
12 #include <set>
13 
14 namespace fwThread
15 {
16 class Worker;
17 }
18 
19 namespace fwCom
20 {
21 
22 template< typename F >
23 struct SlotRun;
24 
30 template< typename ... A >
31 struct SlotRun< void (A ...) > : SlotBase
32 {
33 
37  typedef void SignatureType (A ...);
39  typedef SPTR ( SelfType ) sptr;
40  typedef WPTR ( SelfType ) wptr;
43  SlotRun() :
44  SlotBase( sizeof ... (A) )
45  {
46  }
47 
51  virtual void run(A ... a) const = 0;
52 
62  virtual SlotBase::VoidSharedFutureType asyncRun( const SPTR(::fwThread::Worker)& worker, A ... args ) const;
63 
72  virtual SlotBase::VoidSharedFutureType asyncRun(A ... args) const;
73 
74  protected:
75 
76  template< typename R, typename WEAKCALL >
77  static std::shared_future< R > postWeakCall( const SPTR(::fwThread::Worker)& worker, WEAKCALL f );
78 
84  virtual std::function< void() > bindRun( A ... args ) const;
85 
86 };
87 
88 } // namespace fwCom
89 
90 #endif /* __FWCOM_SLOTRUN_HPP__ */
91 
#define SPTR(_cls_)
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
#define WPTR(_cls_)
Base class for Slot implementations.
Definition: SlotBase.hpp:46
This class creates and manages a task loop. The default implementation create a loop in a new thread...
Definition: Worker.hpp:32
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...
std::shared_future< void > VoidSharedFutureType
SlotBase::asyncRun return type.
Definition: SlotBase.hpp:62