Orocos Real-Time Toolkit
2.6.0
|
Properties can be hierarchically stored and be introspected for their type and contents. More...
Classes | |
class | RTT::ConfigurationInterface |
A class for keeping track of Attribute, Constant and Property objects of a TaskContext. More... | |
class | RTT::Property< T > |
A property represents a named value of any type with a description. More... | |
class | RTT::PropertyBag |
A container for holding references to properties. More... | |
Modules | |
Recursive Property Bag Operations. | |
These functions operate recursively on the contents of bags, possibly modifying, deleting or creating new Property objects in the bag or in one of its sub-bags. | |
Functions | |
PropertyBase * | RTT::findProperty (const PropertyBag &bag, const std::string &path, const std::string &separator=std::string(".")) |
This function locates a Property in nested PropertyBags. | |
vector< string > | RTT::listProperties (const PropertyBag &bag, const std::string &separator=std::string(".")) |
List all properties in a PropertyBag in a single list. | |
vector< string > | RTT::listPropertyDescriptions (const PropertyBag &bag, const std::string &separator=std::string(".")) |
List all descriptions of properties in a PropertyBag in a single list. | |
bool | RTT::storeProperty (PropertyBag &bag, const std::string &path, base::PropertyBase *item, const std::string &separator=std::string(".")) |
Stores a property in a bag given a certain path with transfer of ownership. | |
bool | RTT::removeProperty (PropertyBag &bag, const std::string &path, const std::string &separator=std::string(".")) |
Removes a property from a bag given a certain path. | |
bool | RTT::refreshProperties (const PropertyBag &target, const PropertyBag &source, bool strict=false) |
This function refreshes the values of the properties in one PropertyBag with the values of the properties of another PropertyBag. | |
bool | RTT::refreshProperty (const PropertyBag &target, const base::PropertyBase &source) |
Refresh one Property in the target bag with the new value. | |
bool | RTT::copyProperties (PropertyBag &target, const PropertyBag &source) |
This function copies (recursively) the Properties of one Bag into another Bag. | |
bool | RTT::updateProperties (PropertyBag &target, const PropertyBag &source) |
This function updates (recursively) the values of Property objects of one Bag with the values of Property objects of another bag. | |
bool | RTT::updateProperty (PropertyBag &target, const PropertyBag &source, const std::string &path, const std::string &separator=".") |
This function updates (recursively) the values of a single Property object of one Bag with the property of another bag. | |
bool | RTT::refreshProperty (PropertyBag &target, const PropertyBag &source, const std::string &path, const std::string &separator=".") |
This function refreshes (recursively) the values of a single Property object of one Bag with the property of another bag. | |
void | RTT::deleteProperties (PropertyBag &target) |
This function iterates over a PropertyBag and deletes all Property objects in it without recursion. | |
void | RTT::deletePropertyBag (PropertyBag &target) |
This function iterates over a PropertyBag and recursively deletes all Property objects. | |
void | RTT::flattenPropertyBag (PropertyBag &target, const std::string &separator=".") |
This function flattens a PropertyBag recursively. |
Properties can be hierarchically stored and be introspected for their type and contents.
Properties can be (de-)serialised using Marshallers and Demarshallers.
RTT_API bool RTT::copyProperties | ( | PropertyBag & | target, |
const PropertyBag & | source | ||
) |
This function copies (recursively) the Properties of one Bag into another Bag.
This may cause duplicate entries in target if source contains Properties with the same name. Use updateProperties to avoid duplicates and update exiting Properties.
target | The bag in which the properties must be copied. |
source | The bag containing properties for target. |
Definition at line 542 of file PropertyBag.cpp.
References RTT::PropertyBag::add(), RTT::base::PropertyBase::copy(), RTT::base::PropertyBase::create(), and RTT::PropertyBag::getProperties().
Referenced by RTT::marsh::PropertyLoader::load().
RTT_API void RTT::deleteProperties | ( | PropertyBag & | target | ) |
This function iterates over a PropertyBag and deletes all Property objects in it without recursion.
This function respects ownership, that is, it deletes the properties that are not owned by target and simply removes properties which are owned by target, such that target can do the cleanup.
Definition at line 742 of file PropertyBag.cpp.
References RTT::PropertyBag::clear(), RTT::PropertyBag::getProperties(), and RTT::PropertyBag::ownsProperty().
Referenced by RTT::extras::decomposeProperty().
RTT_API void RTT::deletePropertyBag | ( | PropertyBag & | target | ) |
This function iterates over a PropertyBag and recursively deletes all Property objects.
This function respects ownership, that is, it deletes the properties that are not owned by target and simply removes properties which are owned by target, such that target can do the cleanup.
Definition at line 756 of file PropertyBag.cpp.
References RTT::PropertyBag::clear(), RTT::PropertyBag::getProperties(), RTT::PropertyBag::ownsProperty(), and RTT::Property< T >::value().
Referenced by RTT::base::PropertyBagVisitor::introspectAndDecompose(), RTT::marsh::PropertyLoader::load(), and RTT::marsh::PropertyLoader::store().
RTT_API base::PropertyBase * RTT::findProperty | ( | const PropertyBag & | bag, |
const std::string & | path, | ||
const std::string & | separator = std::string(".") |
||
) |
This function locates a Property in nested PropertyBags.
bag | The bag to look for a Property. |
path | A sequence of names, separated by separator indicating the path in the bag to a property, omitting the name of the bag itself. |
separator | The token to separate properties in the path, Defaults to ".". |
Definition at line 309 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), and RTT::Property< T >::rvalue().
Referenced by RTT::removeProperty().
RTT_API void RTT::flattenPropertyBag | ( | PropertyBag & | target, |
const std::string & | separator = "." |
||
) |
This function flattens a PropertyBag recursively.
The names of the Propety objects of the included bags are placed in this bag with the included bag's name prefixed. If the Property object in that bag is also a bag, the same operation is performed recursively. So any bag in target will show up at the root of target with the path prefixed.
Definition at line 774 of file PropertyBag.cpp.
References RTT::PropertyBag::add(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), and RTT::Property< T >::value().
RTT_API std::vector< std::string > RTT::listProperties | ( | const PropertyBag & | bag, |
const std::string & | separator = std::string(".") |
||
) |
List all properties in a PropertyBag in a single list.
The returned list has the form 'item1'...'subbag.subsubbag.itemN', where item1 is a property in bag, subbag is a bag inside bag and subsubbag is a bag in subbag. And so on.
bag | The bag to list the properties of. |
separator | The token to separate properties in the path, Defaults to ".". |
Definition at line 374 of file PropertyBag.cpp.
RTT_API std::vector< std::string > RTT::listPropertyDescriptions | ( | const PropertyBag & | bag, |
const std::string & | separator = std::string(".") |
||
) |
List all descriptions of properties in a PropertyBag in a single list.
The returned list has the same number of items returned by listProperties(bag) and matches its descriptions 1-to-1 with it.
bag | The bag to list the property descriptions of. |
separator | The token to separate properties in the path, Defaults to ".". |
Definition at line 381 of file PropertyBag.cpp.
RTT_API bool RTT::refreshProperties | ( | const PropertyBag & | target, |
const PropertyBag & | source, | ||
bool | strict = false |
||
) |
This function refreshes the values of the properties in one PropertyBag with the values of the properties of another PropertyBag.
No new properties will be created.
You can use this function to update the properties of a fixed bag.
target | The bag in which the properties must be refreshed. |
source | The bag containing new values for target. |
strict | Set to true if each property of target must be updated with a property of source. If a property from target is not present in source, this function returns false. |
Definition at line 494 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), RTT::PropertyBag::getItem(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), RTT::base::PropertyBase::getType(), and RTT::types::Types().
Referenced by RTT::types::BoostArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::SequenceTypeInfoBase< std::vector< double > >::composeType(), RTT::types::CArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::StructTypeInfo< T, has_ostream >::composeTypeImpl(), and RTT::marsh::PropertyLoader::load().
RTT_API bool RTT::refreshProperty | ( | const PropertyBag & | target, |
const base::PropertyBase & | source | ||
) |
Refresh one Property in the target bag with the new value.
target | The bag in which a property with name source->getName() can be found. |
source | A property which contains a new value for a property with the same name in target. |
Definition at line 531 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), and RTT::base::PropertyBase::refresh().
Referenced by RTT::refreshProperty().
RTT_API bool RTT::refreshProperty | ( | PropertyBag & | target, |
const PropertyBag & | source, | ||
const std::string & | path, | ||
const std::string & | separator = "." |
||
) |
This function refreshes (recursively) the values of a single Property object of one Bag with the property of another bag.
It will not create a new Property instances if the Property is not present in the target and hence fail in that case.
target | The bag in which the property exists and must be refreshed. |
source | The bag containing prop as one of its children. |
path | The path to a property in source (or in a sub-bag of source), which must be created or updated in target. |
separator | The token to separate properties in the path, |
Definition at line 687 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), RTT::refreshProperty(), RTT::Property< T >::rvalue(), and RTT::Property< T >::value().
RTT_API bool RTT::removeProperty | ( | PropertyBag & | bag, |
const std::string & | path, | ||
const std::string & | separator = std::string(".") |
||
) |
Removes a property from a bag given a certain path.
This allows you to remove a property directly in (nested) subbags, instead of browsing manually to the required level and then calling PropertyBag::removeProperty().
Definition at line 420 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), RTT::findProperty(), RTT::base::PropertyBase::ready(), RTT::PropertyBag::removeProperty(), and RTT::Property< T >::value().
RTT_API bool RTT::storeProperty | ( | PropertyBag & | bag, |
const std::string & | path, | ||
base::PropertyBase * | item, | ||
const std::string & | separator = std::string(".") |
||
) |
Stores a property in a bag given a certain path with transfer of ownership.
This allows you to store a property directly in (nested) subbags, instead of browsing manually to the required level and then calling PropertyBag::ownProperty().
Definition at line 388 of file PropertyBag.cpp.
References RTT::PropertyBag::find(), RTT::PropertyBag::ownProperty(), and RTT::Property< T >::value().
RTT_API bool RTT::updateProperties | ( | PropertyBag & | target, |
const PropertyBag & | source | ||
) |
This function updates (recursively) the values of Property objects of one Bag with the values of Property objects of another bag.
It creates new Property instances if a Property is not present in the target and updates existing Properties.
Use copyProperties if you want complete duplication.
target | The bag in which the properties must be updated. |
source | The bag containing new values, descriptions or properties for target. |
Definition at line 561 of file PropertyBag.cpp.
References RTT::PropertyBag::add(), RTT::types::TypeInfo::composeType(), RTT::base::PropertyBase::create(), RTT::base::PropertyBase::getDataSource(), RTT::Property< T >::getDataSource(), RTT::base::PropertyBase::getDescription(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), RTT::base::PropertyBase::getTypeInfo(), RTT::PropertyBag::list(), RTT::Logger::log(), RTT::types::Types(), RTT::base::PropertyBase::update(), and RTT::Property< T >::value().
Referenced by RTT::marsh::PropertyLoader::load().
RTT_API bool RTT::updateProperty | ( | PropertyBag & | target, |
const PropertyBag & | source, | ||
const std::string & | path, | ||
const std::string & | separator = "." |
||
) |
This function updates (recursively) the values of a single Property object of one Bag with the property of another bag.
It creates a new Property instances if the Property is not present in the target and updates existing Properties.
Use copyProperties if you want complete duplication.
target | The bag in which the property must be updated. |
source | The bag containing prop as one of its children. |
path | The path to a property in source (or in a sub-bag of source), which must be created or updated in target. |
separator | The token to separate properties in the path, |
Definition at line 630 of file PropertyBag.cpp.
References RTT::base::PropertyBase::create(), RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::ownProperty(), RTT::Property< T >::rvalue(), and RTT::Property< T >::value().