fw4spl
fwRuntime::ConfigurationElement Struct Reference

Defines the configuration element class. More...

#include <ConfigurationElement.hpp>

+ Inheritance diagram for fwRuntime::ConfigurationElement:
+ Collaboration diagram for fwRuntime::ConfigurationElement:

Classes

struct  NoSuchAttribute
 Defines the a class for attributes exceptions. More...
 

Public Types

typedef std::pair< bool, std::string > AttributePair
 Defines the attribute pair type.
 
- Public Types inherited from fwRuntime::ConfigurationElementContainer
typedef std::vector< std::shared_ptr< ConfigurationElement > > Container
 Defines the configuration element container type. More...
 
typedef Container::iterator Iterator
 Defines the configuration element container type. More...
 

Public Member Functions

virtual bool isA (const std::string &type) const
 
FWRUNTIME_API const std::shared_ptr< BundlegetBundle () const noexcept
 Retrieves the bundle the configuration element is attached to. More...
 
FWRUNTIME_API const std::string getAttributeValue (const std::string &name) const noexcept
 Retrieves the value of an attribute for the specified name. More...
 
FWRUNTIME_API const std::string getExistingAttributeValue (const std::string &name) const
 Retrieves the value of an attribute for the specified name. More...
 
FWRUNTIME_API const AttributePair getSafeAttributeValue (const std::string &name) const noexcept
 Retrieves the value of an existing attribute for the specified name. More...
 
FWRUNTIME_API const std::string getName () const noexcept
 Retrieves the name of the configuration element. More...
 
FWRUNTIME_API const std::string getValue () const noexcept
 Retrieves the configuration element value. More...
 
FWRUNTIME_API bool hasAttribute (const std::string &name) const noexcept
 Tells if the specified attributes exists. More...
 
FWRUNTIME_API const std::map< std::string, std::string > getAttributes () const noexcept
 Return the map with attributes.
 
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. More...
 
virtual FWRUNTIME_API ~ConfigurationElement ()
 Used only because this class inherit from enable_shared_from_this.
 
- Public Member Functions inherited from fwRuntime::ConfigurationElementContainer
FWRUNTIME_API Iterator begin ()
 Retrieves the iterator on the first managed configuration element. More...
 
FWRUNTIME_API Iterator end ()
 Retrieves the iterator on the end of the configuration element container. More...
 
FWRUNTIME_API const ContainergetElements () const
 Returns the configuration element container. More...
 
FWRUNTIME_API const std::shared_ptr< ConfigurationElementfindConfigurationElement (const std::string &name) const
 Retrieves the first configuration corresponding to the specified name. More...
 
FWRUNTIME_API bool hasConfigurationElement (const std::string &name) const
 Test if has an configuration corresponding to the specified name. More...
 
FWRUNTIME_API ConfigurationElementContainer findAllConfigurationElement (const std::string &name) const
 Retrieves the configurations corresponding to the specified name. More...
 
FWRUNTIME_API size_t size () const
 Return the number of configurations. More...
 

Static Public Member Functions

static bool isTypeOf (const std::string &type)
 

Protected Member Functions

FWRUNTIME_API ConfigurationElement (const std::shared_ptr< Bundle > bundle, const std::string &name)
 Constructor. More...
 
FWRUNTIME_API void setAttributeValue (const std::string &name, const std::string &value) noexcept
 Sets an attribute with the specified name and value. More...
 
FWRUNTIME_API void setValue (const std::string &value) noexcept
 Sets the value of the configuration element it-self. More...
 
- Protected Member Functions inherited from fwRuntime::ConfigurationElementContainer
FWRUNTIME_API void addConfigurationElement (std::shared_ptr< ConfigurationElement > element)
 Adds a new configuration element to the extension. More...
 

Friends

struct ::fwRuntime::io::BundleDescriptorReader
 
template<class , class , class >
class ::fwTools::ClassFactory
 
class ::fwTools::Factory
 
FWRUNTIME_API friend std::ostream & operator<< (std::ostream &_sstream, ConfigurationElement &_configurationElement)
 Print contents.
 

Demangling methods

virtual const std::string & getClassname () const
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
static const std::string & classname ()
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 

Detailed Description

Defines the configuration element class.

Deprecated:
use ::boost::property::ptree instead.

Definition at line 39 of file ConfigurationElement.hpp.

Constructor & Destructor Documentation

fwRuntime::ConfigurationElement::ConfigurationElement ( const std::shared_ptr< Bundle bundle,
const std::string &  name 
)
protected

Constructor.

Parameters
[in]bundlea shared pointer to the bundle to the configuration element is attached to
[in]namea string containing the configuration element name

Definition at line 42 of file ConfigurationElement.cpp.

Member Function Documentation

std::vector< ConfigurationElement::sptr > fwRuntime::ConfigurationElement::find ( std::string  name = "",
std::string  attribute = "",
std::string  attributeValue = "",
int  depth = 1 
)

Find recursively all the corresponding configuration elements.

Parameters
[in]namename of the configuration element (if name is empty, find all name)
[in]attributeattribute which must be contained by the configuration element ( if attribute is empty, this doesn't check the attribute)
[in]attributeValuevalue of the attribute which must be contained by the configuration element ( if value is empty, this doesn't check the value )
[in]depthdepth of the recursion

Definition at line 143 of file ConfigurationElement.cpp.

References fwRuntime::ConfigurationElementContainer::begin(), fwRuntime::ConfigurationElementContainer::end(), getAttributeValue(), getName(), and hasAttribute().

Referenced by fwServices::helper::Config::parseService().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string fwRuntime::ConfigurationElement::getAttributeValue ( const std::string &  name) const
noexcept

Retrieves the value of an attribute for the specified name.

This method will search for an attribute having the specified name and return it's value. When no matching attribute is found, an empty string is returned.

Parameters
[in]namea string containing an attribute value
Returns
a string containing the attribute value or nothing when none has been found
See also
getExistingAttributeValue
getSafeAttributeValue

Definition at line 58 of file ConfigurationElement.cpp.

Referenced by find(), and fwServices::helper::Config::parseService().

+ Here is the caller graph for this function:

const std::shared_ptr< Bundle > fwRuntime::ConfigurationElement::getBundle ( ) const
noexcept

Retrieves the bundle the configuration element is attached to.

Returns
a shared pointer to a bundle instance

Definition at line 51 of file ConfigurationElement.cpp.

const std::string fwRuntime::ConfigurationElement::getExistingAttributeValue ( const std::string &  name) const

Retrieves the value of an attribute for the specified name.

This method will search for an attribute having the specified name and return it's value. When no matching attribute is found, an object of type NoSuchAttribute is thrown.

Parameters
[in]namea string containing an attribute name
Returns
a string containing an attribute value
Exceptions
NoSuchAttributeno attribute with the specified name has been found
See also
getAttributeValue
getSafeAttributeValue

Definition at line 66 of file ConfigurationElement.cpp.

Referenced by fwServices::helper::Config::createProxy().

+ Here is the caller graph for this function:

const std::string fwRuntime::ConfigurationElement::getName ( ) const
noexcept

Retrieves the name of the configuration element.

Returns
a string containing the configuration element name

Definition at line 94 of file ConfigurationElement.cpp.

Referenced by find(), and fwServices::helper::Config::parseService().

+ Here is the caller graph for this function:

const ConfigurationElement::AttributePair fwRuntime::ConfigurationElement::getSafeAttributeValue ( const std::string &  name) const
noexcept

Retrieves the value of an existing attribute for the specified name.

The returned value is a pair where the first element is a boolean telling if the attribute really exists and the second element is the attribute value.

Parameters
[in]namea string containing an attribute name
Returns
a pair where the first element is a boolean telling if the attribute really exists and the second element is the attribute value
See also
getAttributeValue
getExistingAttributeValue

Definition at line 78 of file ConfigurationElement.cpp.

Referenced by fwServices::helper::Config::parseService().

+ Here is the caller graph for this function:

const std::string fwRuntime::ConfigurationElement::getValue ( ) const
noexcept

Retrieves the configuration element value.

Returns
a string containing the configuration element value

Definition at line 101 of file ConfigurationElement.cpp.

bool fwRuntime::ConfigurationElement::hasAttribute ( const std::string &  name) const
noexcept

Tells if the specified attributes exists.

Parameters
[in]namea string containing an attribute name
Returns
true or false

Definition at line 108 of file ConfigurationElement.cpp.

Referenced by fwServices::helper::Config::createProxy(), and find().

+ Here is the caller graph for this function:

void fwRuntime::ConfigurationElement::setAttributeValue ( const std::string &  name,
const std::string &  value 
)
protectednoexcept

Sets an attribute with the specified name and value.

Setting a value for an existing attribute will override the old value.

Parameters
[in]namea string containing the attribute name
[in]valuea string containing the attribute value

Definition at line 123 of file ConfigurationElement.cpp.

Referenced by fwRuntime::EConfigurationElement::addConfigurationElement().

+ Here is the caller graph for this function:

void fwRuntime::ConfigurationElement::setValue ( const std::string &  value)
protectednoexcept

Sets the value of the configuration element it-self.

Parameters
[in]valuea string containing the new configuration element value

Definition at line 130 of file ConfigurationElement.cpp.

Referenced by fwRuntime::EConfigurationElement::addConfigurationElement().

+ Here is the caller graph for this function:


The documentation for this struct was generated from the following files: