7 #ifndef __FWCOM_SLOT_HXX__ 8 #define __FWCOM_SLOT_HXX__ 10 #ifndef __FWCOM_SLOT_HPP__ 11 #error fwCom/Slot.hpp not included 14 #include "fwCom/SlotCall.hxx" 15 #include "fwCom/util/AutoBind.hpp" 16 #include "fwCom/util/AutoBind.hxx" 18 #include <boost/function_types/function_arity.hpp> 19 #include <boost/function_types/result_type.hpp> 20 #include <boost/static_assert.hpp> 22 #include <type_traits> 29 template<
typename R,
typename ... A >
30 Slot< R( A ... ) >::Slot() :
31 SlotCall< R(A ...) >()
39 template<
typename R,
typename ... A >
41 SPTR( Slot< R( A ... ) > ) Slot< R( A ... ) >::New( F f )
48 template<
typename R,
typename ... A >
49 template<
typename F,
typename O>
50 SPTR( Slot< R( A ... ) > ) Slot< R( A ... ) >::New( F f, O o )
58 template<
typename R,
typename ... A >
59 template<
typename F >
60 Slot< Slot< R( A ... ) > >::Slot(
SPTR( SlotRun< F > )slot ) :
62 ::
fwCom::util::AutoBind<
64 ::
boost::function_types::function_arity< F >::value
65 >::wrap( &SlotRun< F >::run, slot.get() ) )
67 BOOST_STATIC_ASSERT( (std::is_same<void, R>::value) );
68 this->setWorker(slot->getWorker());
73 template<
typename R,
typename ... A >
74 template<
typename F >
75 Slot< Slot< R( A ... ) > >::Slot(
SPTR( Slot< F > )slot ) :
77 ::
fwCom::util::AutoBind<
79 ::
boost::function_types::function_arity< F >::value
80 >::wrap( &Slot< F >::call, slot.get() ) )
82 this->setWorker(slot->getWorker());
87 template<
typename R,
typename ... A >
89 SPTR(Slot< R( A ... )>) Slot< Slot< R( A ... )> >::New(
SPTR( SlotRun< F > ) slot )
91 assert(::boost::function_types::function_arity< F >::value <=
92 ::boost::function_types::function_arity< R( A ... ) >::value);
93 return std::make_shared< Slot< Slot< R( A ... ) > > >( slot );
98 template<
typename F,
typename ... BINDING>
99 SPTR(Slot< typename ::fwCom::util::convert_function_type< F >::type >) newSlot(F f, BINDING ... binding)
101 SLM_ASSERT(
"Too many arguments", (
sizeof ... (binding) < 2 ) );
102 typedef std::function< typename ::fwCom::util::convert_function_type< F >::type > FunctionType;
103 FunctionType func = ::fwCom::util::autobind(f, binding ...);
104 return std::make_shared< Slot< FunctionType > > ( func );
Namespace containing fw4spl communication tools.
std::string getTypeName() const
Returns F typeid name.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
std::string m_signature
Slot's signature based on typeid.