fw4spl
SSignal.cpp
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 #include "gui/action/SSignal.hpp"
8 
9 #include <fwCom/Signal.hxx>
10 
11 #include <fwGui/dialog/MessageDialog.hpp>
12 
13 #include <fwServices/macros.hpp>
14 
15 namespace gui
16 {
17 namespace action
18 {
19 
20 //-----------------------------------------------------------------------------
21 
22 fwServicesRegisterMacro( ::fwGui::IActionSrv, ::gui::action::SSignal );
23 
24 static const ::fwCom::Signals::SignalKeyType s_TRIGGERED_SIG = "triggered";
25 static const ::fwCom::Signals::SignalKeyType s_CANCELLED_SIG = "cancelled";
26 
27 //-----------------------------------------------------------------------------
28 
29 SSignal::SSignal() noexcept :
30  m_sigTriggered(TriggeredSignalType::New()),
31  m_sigCancelled(TriggeredSignalType::New())
32 {
33  m_sigTriggered = newSignal<TriggeredSignalType>(s_TRIGGERED_SIG);
34  m_sigCancelled = newSignal<TriggeredSignalType>(s_CANCELLED_SIG);
35 }
36 
37 //-----------------------------------------------------------------------------
38 
40 {
41 }
42 
43 //-----------------------------------------------------------------------------
44 
46 {
47  this->initialize();
48 }
49 
50 //-----------------------------------------------------------------------------
51 
53 {
54  this->actionServiceStarting();
55 }
56 
57 //-----------------------------------------------------------------------------
58 
60 {
61  this->actionServiceStopping();
62 }
63 
64 //-----------------------------------------------------------------------------
65 
66 void SSignal::info(std::ostream& _sstream )
67 {
68  _sstream << "Starter Action" << std::endl;
69 }
70 
71 //-----------------------------------------------------------------------------
72 
74 {
76  if (this->confirmAction())
77  {
78  m_sigTriggered->asyncEmit(this->getIsActive());
79  }
80  else
81  {
82  m_sigCancelled->asyncEmit(this->getIsActive());
83  }
84 
85 }
86 
87 //-----------------------------------------------------------------------------
88 
89 } // namespace action
90 } // namespace gui
91 
FWGUI_API bool confirmAction()
Confirm that the action must be executed.
Definition: IActionSrv.cpp:271
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
Definition: IActionSrv.cpp:160
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
The namespace gui contains the basic services to build the application IHM.
Action that sends a signal when it is triggered.
Definition: SSignal.hpp:36
GUI_API void configuring() override
Configures the service.
Definition: SSignal.cpp:45
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Definition: IActionSrv.cpp:153
virtual GUI_API void stopping() override
Unregister the action.
Definition: SSignal.cpp:59
FWGUI_API bool getIsActive() const
Return true if action service is active.
Definition: IActionSrv.cpp:198
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
virtual GUI_API ~SSignal() noexcept
Destructor. Do nothing.
Definition: SSignal.cpp:39
virtual GUI_API void starting() override
Register the action and check if the action is executable.
Definition: SSignal.cpp:52
virtual GUI_API void info(std::ostream &_sstream) override
Give information about the class. Do nothing.
Definition: SSignal.cpp:66
GUI_API SSignal() noexcept
Constructor. Do nothing.
Definition: SSignal.cpp:29
FWGUI_API void initialize()
Initialize the action.
Definition: IActionSrv.cpp:69
std::shared_ptr< TriggeredSignalType > m_sigTriggered
Signal trigerred when action has been triggered.
Definition: SSignal.hpp:75
GUI_API void updating() override
Emit the signal.
Definition: SSignal.cpp:73
std::shared_ptr< TriggeredSignalType > m_sigCancelled
Signal trigerred when action has been cancelled.
Definition: SSignal.hpp:77