7 #include "ctrlCamp/SExtractObj.hpp" 9 #include <fwData/mt/ObjectWriteLock.hpp> 11 #include <fwDataCamp/exception/NullPointer.hpp> 12 #include <fwDataCamp/exception/ObjectNotFound.hpp> 13 #include <fwDataCamp/getObject.hpp> 15 #include <fwServices/registry/ObjectService.hpp> 39 typedef ::fwRuntime::ConfigurationElement::sptr ConfigurationType;
41 const ConfigurationType inoutCfg =
m_configuration->findConfigurationElement(
"inout");
42 SLM_ASSERT(
"At one 'inout' tag is required.", inoutCfg);
44 const std::vector< ConfigurationType > extractCfg = inoutCfg->find(
"extract");
45 SLM_ASSERT(
"At least one 'extract' tag is required.", !extractCfg.empty());
47 const ConfigurationType outCfg =
m_configuration->findConfigurationElement(
"out");
49 const std::vector< ConfigurationType > outKeyCfg = outCfg->find(
"key");
50 SLM_ASSERT(
"You must have as many 'from' tags as 'out' keys.", extractCfg.size() == outKeyCfg.size());
52 for(ConfigurationType cfg : extractCfg)
54 SLM_ASSERT(
"Missing attribute 'from'.", cfg->hasAttribute(
"from"));
55 const std::string from = cfg->getAttributeValue(
"from");
57 m_sourcePaths.push_back(from);
71 auto sourceObject = this->getInOut< ::fwData::Object >(
"source");
74 for(
auto path : m_sourcePaths)
76 const std::string from = path;
78 ::fwData::Object::sptr object;
81 object = ::fwDataCamp::getObject( sourceObject, from,
true );
85 this->
setOutput(
"target",
nullptr, index);
89 SLM_WARN(
"Object from '"+ from +
"' not found");
91 catch(std::exception& e)
93 OSLM_FATAL(
"Unhandled exception: " << e.what());
96 SLM_WARN_IF(
"Object from '"+ from +
"' not found", !
object);
The namespace ctrlCamp contains services using camp.
#define SLM_WARN(message)
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.
This interface defines service API. It can be considered as a default type for services using fwCamp...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Object not found exception.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
size_t getKeyGroupSize(const KeyType &keybase) const
Return the number of key in a group of keys.
#define OSLM_FATAL(message)
#define SLM_WARN_IF(message, cond)