7 #include "gui/action/SStarter.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwGui/dialog/MessageDialog.hpp> 13 #include <fwRuntime/Extension.hpp> 14 #include <fwRuntime/helper.hpp> 16 #include <fwServices/macros.hpp> 17 #include <fwServices/op/Get.hpp> 19 #include <fwTools/fwID.hpp> 21 #include <boost/range/adaptor/reversed.hpp> 53 std::vector< ::fwServices::IService::SharedFutureType > futures;
55 for( VectPairIDActionType::value_type serviceUid : ::boost::adaptors::reverse(m_uuidServices) )
58 if (srv_exists && (m_idStartedSrvSet.find(serviceUid.first) != m_idStartedSrvSet.end()) )
60 ::fwServices::IService::sptr service = ::fwServices::get( serviceUid.first );
61 if (service->isStarted())
63 futures.push_back(service->stop());
68 std::for_each(futures.begin(), futures.end(), std::mem_fn(&::std::shared_future<void>::wait));
77 _sstream <<
"Starter Action" << std::endl;
84 for(
size_t i = 0; i < m_uuidServices.size(); i++)
86 ActionType action = m_uuidServices.at(i).second;
87 IDSrvType uid = m_uuidServices.at(i).first;
91 if ( action == START_IF_EXISTS )
102 else if( action == STOP_IF_EXISTS )
114 if( action != DO_NOTHING)
118 ::fwServices::IService::sptr service = ::fwServices::get( uid );
124 if(service->isStopped())
128 m_idStartedSrvSet.insert(uid);
133 m_idStartedSrvSet.erase(uid);
137 case START_ONLY_OR_STOP:
139 if(service->isStopped())
142 m_idStartedSrvSet.insert(uid);
147 m_idStartedSrvSet.erase(uid);
153 if(service->isStopped())
156 m_idStartedSrvSet.insert(uid);
160 OSLM_WARN(
"Service " << service->getID() <<
" is not stopped");
167 if(service->isStarted())
173 OSLM_WARN(
"Service " << service->getID() <<
" is not started");
179 if(service->isStopped())
182 m_idStartedSrvSet.insert(uid);
186 OSLM_WARN(
"Service " << service->getID() <<
" is not stopped");
193 <<
") type corresponding to the action id requested for " << uid <<
202 "Service unavailable",
203 "The service is unavailable.",
204 ::fwGui::dialog::IMessageDialog::WARNING);
206 OSLM_INFO(
"Do nothing for Service " << m_uuidServices.at(i).first);
219 OSLM_INFO(
"SStarter " << actionCfg->getName());
221 std::string actionType = actionCfg->getName();
223 if ( actionType ==
"start" )
227 else if ( actionType ==
"stop" )
231 else if ( actionType ==
"start_or_stop" )
233 action = START_OR_STOP;
235 else if ( actionType ==
"start_only_or_stop" )
237 action = START_ONLY_OR_STOP;
239 else if ( actionType ==
"start_if_exists" )
241 action = START_IF_EXISTS;
243 else if ( actionType ==
"stop_if_exists" )
245 action = STOP_IF_EXISTS;
247 else if ( actionType ==
"start_only" )
253 OSLM_WARN(
"The \"actionType\":" << actionType <<
" is not managed by SStarter");
256 SLM_ASSERT(
"Attribute uid missing", actionCfg->hasAttribute(
"uid"));
257 IDSrvType uuid = actionCfg->getExistingAttributeValue(
"uid");
259 m_uuidServices.push_back( std::make_pair(uuid, action) );
GUI_API void configuring() override
This method is used to configure the service parameters: specifies which services must be started or ...
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
virtual GUI_API void starting() override
Initialize the service activity.
virtual GUI_API void stopping() override
Uninitialized the service activity. All services started by this action are stopped.
The namespace gui contains the basic services to build the application IHM.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
#define OSLM_INFO(message)
GUI_API void updating() override
This method starts-updates or stops the specified services.
virtual GUI_API ~SStarter() noexcept
Destructor. Do nothing.
Defines the service interface managing the menu items.
virtual GUI_API void info(std::ostream &_sstream) override
This method gives information about the class. Do nothing.
GUI_API SStarter() noexcept
Constructor. Do nothing.
#define OSLM_WARN(message)
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void initialize()
Initialize the action.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
#define OSLM_FATAL(message)
Apply an action (start, stop, ...) on a service specify by uid.