7 #include "fwRuntime/ConfigurationElement.hpp" 9 #include "fwRuntime/Bundle.hpp" 10 #include "fwRuntime/IExecutable.hpp" 11 #include "fwRuntime/RuntimeException.hpp" 13 #include <fwCore/base.hpp> 22 _sstream <<
"Configuration element " << _configurationElement.
getName() <<
" value = " <<
23 _configurationElement.
getValue() << std::endl;
24 for(ConfigurationElement::AttributeContainer::iterator iter = _configurationElement.m_attributes.begin();
25 iter != _configurationElement.m_attributes.end(); ++iter )
27 _sstream <<
"Id = " << iter->first <<
" with value " << iter->second << std::endl;
29 _sstream <<
"Subelement : " << std::endl;
30 for(ConfigurationElementContainer::Container::iterator iter = _configurationElement.
begin();
31 iter != _configurationElement.
end(); ++iter )
34 _sstream << std::endl << *(*iter) << std::endl;
45 m_value(
std::string(
"") )
53 return m_bundle.lock();
60 AttributeContainer::const_iterator foundPos = m_attributes.find(name);
61 return foundPos == m_attributes.end() ? std::string() : foundPos->second;
68 AttributeContainer::const_iterator foundPos = m_attributes.find(name);
69 if(foundPos == m_attributes.end())
73 return foundPos->second;
81 AttributeContainer::const_iterator foundPos = m_attributes.find(name);
82 if(foundPos == m_attributes.end())
110 AttributeContainer::const_iterator foundPos = m_attributes.find(name);
111 return foundPos != m_attributes.end();
125 m_attributes[name] = value;
145 std::string attribute,
146 std::string attributeValue,
150 typedef std::vector < ConfigurationElement::sptr > ConfVector;
153 bool nameOk = (name.empty() || this->
getName() == name);
154 bool attributeOk = (attribute.empty() || this->
hasAttribute(attribute));
155 bool attributeValueOk =
156 (attributeValue.empty() ||
158 if (nameOk && attributeOk && attributeValueOk)
160 result.push_back(this->shared_from_this());
166 for (iter = this->
begin(); iter != this->
end(); ++iter)
169 deepConf = (*iter)->find(name, attribute, attributeValue, depth-1);
170 result.insert(result.end(), deepConf.begin(), deepConf.end());
FWRUNTIME_API const std::map< std::string, std::string > getAttributes() const noexcept
Return the map with attributes.
FWRUNTIME_API Iterator begin()
Retrieves the iterator on the first managed configuration element.
FWRUNTIME_API void setValue(const std::string &value) noexcept
Sets the value of the configuration element it-self.
virtual FWRUNTIME_API ~ConfigurationElement()
Used only because this class inherit from enable_shared_from_this.
FWRUNTIME_API bool hasAttribute(const std::string &name) const noexcept
Tells if the specified attributes exists.
std::pair< bool, std::string > AttributePair
Defines the attribute pair type.
Defines the configuration element class.
FWRUNTIME_API std::vector< ConfigurationElement::sptr > find(std::string name="", std::string attribute="", std::string attributeValue="", int depth=1)
Find recursively all the corresponding configuration elements.
FWRUNTIME_API const std::string getExistingAttributeValue(const std::string &name) const
Retrieves the value of an attribute for the specified name.
FWRUNTIME_API const std::string getAttributeValue(const std::string &name) const noexcept
Retrieves the value of an attribute for the specified name.
FWRUNTIME_API const std::string getName() const noexcept
Retrieves the name of the configuration element.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
FWRUNTIME_API const AttributePair getSafeAttributeValue(const std::string &name) const noexcept
Retrieves the value of an existing attribute for the specified name.
FWRUNTIME_API void setAttributeValue(const std::string &name, const std::string &value) noexcept
Sets an attribute with the specified name and value.
FWRUNTIME_API ConfigurationElement(const std::shared_ptr< Bundle > bundle, const std::string &name)
Constructor.
FWRUNTIME_API const std::shared_ptr< Bundle > getBundle() const noexcept
Retrieves the bundle the configuration element is attached to.
FWRUNTIME_API Iterator end()
Retrieves the iterator on the end of the configuration element container.
Container::iterator Iterator
Defines the configuration element container type.
FWRUNTIME_API const std::string getValue() const noexcept
Retrieves the configuration element value.
Defines the a class for attributes exceptions.