fw4spl
SlotBase.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
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 
8 #include "fwCom/exception/BadRun.hpp"
9 
10 #include "fwCom/SlotBase.hpp"
11 #include "fwCom/SlotBase.hxx"
12 
13 namespace fwCom
14 {
15 
16 void SlotBase::run() const
17 {
18  typedef SlotRun< void () > SlotFuncType;
19  const SlotFuncType *fun = dynamic_cast< const SlotFuncType* >(this);
20  if(fun)
21  {
22  fun->run();
23  }
24  else
25  {
26  OSLM_ERROR( "failed to run : " + m_signature + " with " + SlotBase::getTypeName< void() >() );
27  FW_RAISE_EXCEPTION( fwCom::exception::BadRun( "Failed to find right signature for run" ) );
28  }
29 }
30 
31 //-----------------------------------------------------------------------------
32 
33 SlotBase::VoidSharedFutureType SlotBase::asyncRun() const
34 {
35  typedef SlotRun< void () > SlotFuncType;
36  const SlotFuncType *fun = dynamic_cast< const SlotFuncType* >(this);
37  if(fun)
38  {
39  return fun->asyncRun();
40  }
41  else
42  {
43  OSLM_ERROR( "failed to asyncRun : " + m_signature + " with " + SlotBase::getTypeName< void() >() );
44  FW_RAISE_EXCEPTION( fwCom::exception::BadRun( "Failed to find right signature for asyncRun" ) );
45  }
46 }
47 
48 } // namespace fwCom
49 
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
std::string getTypeName() const
Returns F typeid name.
Definition: SlotBase.hpp:205
#define OSLM_ERROR(message)
Definition: spyLog.hpp:274
Bad run exception.
Definition: BadRun.hpp:20
std::shared_future< void > VoidSharedFutureType
SlotBase::asyncRun return type.
Definition: SlotBase.hpp:62
std::string m_signature
Slot&#39;s signature based on typeid.
Definition: SlotBase.hpp:217