7 #include "dataReg/parser/Object.hpp" 9 #include <fwServices/macros.hpp> 11 #include <boost/foreach.hpp> 34 bool Object::refObjectValidator( ::fwRuntime::ConfigurationElement::csptr _cfgElement )
38 for( ::fwRuntime::ConfigurationElement::csptr elem : _cfgElement->getElements() )
40 std::string subElementName = elem->getName();
41 if( subElementName !=
"service" &&
42 subElementName !=
"serviceList" )
45 "xml subelement \""<< subElementName <<
46 "\" for element object is not supported for the moment when you use a reference on item composite.");
58 SLM_FATAL(
"This method is deprecated, and thus, shouldn't be used.");
63 void Object::createConfig( ::fwTools::Object::sptr _obj )
66 const std::string OBJECT_BUILD_MODE =
"src";
67 const std::string BUILD_OBJECT =
"new";
68 const std::string GET_OBJECT =
"ref";
70 ::fwData::Object::sptr associatedObject = ::fwData::Object::dynamicCast(_obj);
71 SLM_ASSERT(
"associatedObject not instanced", associatedObject);
73 for( ::fwRuntime::ConfigurationElement::csptr elem : m_cfg->getElements() )
76 if( elem->getName() ==
"item" )
79 std::string buildMode = BUILD_OBJECT;
81 if ( elem->hasAttribute( OBJECT_BUILD_MODE ) )
83 buildMode = elem->getExistingAttributeValue( OBJECT_BUILD_MODE );
84 OSLM_ASSERT(
"The buildMode \""<< buildMode <<
"\" is not supported, it should either be BUILD_OBJECT " 86 buildMode == BUILD_OBJECT || buildMode == GET_OBJECT );
89 SLM_ASSERT(
"The xml element \"item\" must have an attribute named \"key\" .",
90 elem->hasAttribute(
"key") );
91 std::string key = elem->getExistingAttributeValue(
"key");
92 SLM_ASSERT(
"The xml element \"item\" must have an attribute named \"key\" whick is not empty.",
94 SLM_ASSERT(
"The xml element \"item\" must have one (and only one) xml sub-element \"object\".",
95 elem->size() == 1 && (*(elem->getElements().begin()))->getName() ==
"object" );
97 if( buildMode == BUILD_OBJECT )
100 OSLM_ASSERT(
"The key "<< key <<
" already exists in the object.", !associatedObject->getField(
105 ctm->::fwServices::IAppConfigManager::setConfig( elem );
107 m_ctmContainer.push_back( ctm );
109 ::fwData::Object::sptr localObj = ctm->getConfigRoot();
112 associatedObject->setField(key, localObj);
125 void Object::startConfig()
127 for( ::fwServices::IAppConfigManager::sptr ctm : m_ctmContainer )
135 void Object::updateConfig()
137 for( ::fwServices::IAppConfigManager::sptr ctm : m_ctmContainer )
145 void Object::stopConfig()
147 BOOST_REVERSE_FOREACH( ::fwServices::IAppConfigManager::sptr ctm, m_ctmContainer )
155 void Object::destroyConfig()
157 BOOST_REVERSE_FOREACH( ::fwServices::IAppConfigManager::sptr ctm, m_ctmContainer )
161 m_ctmContainer.clear();
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Specific fwTools::Object parser. Does nothing as no IService method is specialized: IXMLParser base c...
The namespace dataReg (data registration) contains classes which allow to parse the xml configuration...
#define SLM_FATAL(message)
#define OSLM_ERROR(message)
void updating() override
Parse the XML configuration.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Base class for each data object.
static FWSERVICES_API std::shared_ptr< IAppConfigManager > New()
Service type for the construction of an object and associated services from an XML-based description...