7 #include "gui/action/SPushObject.hpp" 9 #include <fwCom/Slots.hpp> 10 #include <fwCom/Slots.hxx> 12 #include <fwData/Composite.hpp> 14 #include <fwDataTools/helper/Composite.hpp> 16 #include <fwRuntime/ConfigurationElement.hpp> 17 #include <fwRuntime/EConfigurationElement.hpp> 19 #include <fwServices/macros.hpp> 20 #include <fwServices/registry/AppConfig.hpp> 21 #include <fwServices/registry/ObjectService.hpp> 23 #include <fwTools/fwID.hpp> 25 #include <boost/regex.hpp> 32 static const ::fwCom::Slots::SlotKeyType s_UPDATE_OBJECTS_SLOT =
"updateObject";
34 static const std::string s_SOURCE_KEY =
"source";
35 static const std::string s_DESTINATION_KEY =
"destination";
45 newSlot(s_UPDATE_OBJECTS_SLOT, &SPushObject::updateObjects,
this);
60 const ConfigurationType pushCfg =
m_configuration->findConfigurationElement(
"push");
62 SLM_ASSERT(
"<push> tag must have one attribute 'srcKey'.", pushCfg->hasAttribute(
"srcKey"));
63 m_srcKey = pushCfg->getAttributeValue(
"srcKey");
71 this->updateObjects();
85 ::fwData::Composite::sptr compositeSrc = this->getInOut< ::fwData::Composite >(s_SOURCE_KEY);
86 SLM_ASSERT( s_SOURCE_KEY +
" doesn't exist or is not a composite", compositeSrc);
90 SLM_WARN_IF(
"'" + m_srcKey +
"' not found in composite '" + compositeSrc->getID() +
"'", obj ==
nullptr);
94 this->
setOutput(s_DESTINATION_KEY,
nullptr);
104 void SPushObject::updateObjects()
106 ::fwData::Composite::sptr compositeSrc = this->getInOut< ::fwData::Composite >(s_SOURCE_KEY);
107 SLM_ASSERT( s_SOURCE_KEY +
" doesn't exist or is not a composite", compositeSrc);
109 const bool executable = (compositeSrc->find(m_srcKey) != compositeSrc->end());
110 OSLM_TRACE(
"start check : " << compositeSrc->getID() <<
"[" << m_srcKey <<
"] : " <<
111 (compositeSrc->find(m_srcKey) != compositeSrc->end()) );
This class is a helper to define the connections of a service and its data.
virtual FWGUI_API void setIsExecutable(bool isExecutable)
Set the action service executable or not.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
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_TRACE(message)
virtual void updating() override
Extract the object.
FWGUI_API bool getIsActive() const
Return true if action service is active.
Defines the service interface managing the menu items.
virtual GUI_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
To add or remove an object in composite with specific key.
FWSERVICES_API void setOutput(const ::fwServices::IService::KeyType &key, const ::fwData::Object::sptr &object, size_t index=0)
Register an output object at a given key in the OSR, replacing it if it already exists.
GUI_API SPushObject() noexcept
Constructor. Do nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_OBJECTS_SIG
Type of signal when objects are added.
#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.
Base class for each data object.
virtual void configuring() override
Configure the service.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
virtual void starting() override
Register the action and check if the action is executable.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_OBJECTS_SIG
Type of signal when objects are added.
virtual void stopping() override
Unregister the action.
This class defines a composite object.
virtual GUI_API ~SPushObject() noexcept
Destructor. Do nothing.
FWSERVICES_API bool isRegistered(const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service)
Return true if a key is registered for a given service.
#define SLM_WARN_IF(message, cond)