Orocos Real-Time Toolkit  2.9.0
Modules | Classes | Functions

Properties can be hierarchically stored and be introspected for their type and contents. 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.

 

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...
 

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. More...
 
vector< string > RTT::listProperties (const PropertyBag &bag, const std::string &separator=std::string("."))
 List all properties in a PropertyBag in a single list. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool RTT::refreshProperty (const PropertyBag &target, const base::PropertyBase &source)
 Refresh one Property in the target bag with the new value. More...
 
bool RTT::copyProperties (PropertyBag &target, const PropertyBag &source)
 This function copies (recursively) the Properties of one Bag into another Bag. More...
 
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. More...
 
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. More...
 
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. More...
 
void RTT::deleteProperties (PropertyBag &target)
 This function iterates over a PropertyBag and deletes all Property objects in it without recursion. More...
 
void RTT::deletePropertyBag (PropertyBag &target)
 This function iterates over a PropertyBag and recursively deletes all Property objects. More...
 
void RTT::flattenPropertyBag (PropertyBag &target, const std::string &separator=".")
 This function flattens a PropertyBag recursively. More...
 

Detailed Description

Properties can be hierarchically stored and be introspected for their type and contents.

Properties can be (de-)serialised using Marshallers and Demarshallers.

Function Documentation

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.

Parameters
targetThe bag in which the properties must be copied.
sourceThe bag containing properties for target.

Definition at line 538 of file PropertyBag.cpp.

References RTT::base::PropertyBase::copy(), RTT::base::PropertyBase::create(), RTT::PropertyBag::getProperties(), and RTT::PropertyBag::ownProperty().

Referenced by RTT::Property< T >::copy(), and 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.

Postcondition
All objects in this bag are deleted and no elements reside in the bag anymore.

Definition at line 738 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.

Postcondition
All objects in this bag (and possible subbags) are deleted and no elements reside in the bag anymore.

Definition at line 752 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(), RTT::marsh::PropertyLoader::store(), and RTT::corba::TaskContextProxy::~TaskContextProxy().

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.

Parameters
bagThe bag to look for a Property.
pathA sequence of names, separated by separator indicating the path in the bag to a property, omitting the name of the bag itself.
separatorThe token to separate properties in the path, Defaults to ".".

Definition at line 305 of file PropertyBag.cpp.

References RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), RTT::base::PropertyBase::ready(), RTT::Property< T >::rvalue(), and RTT::Property< T >::value().

Referenced by RTT_corba_CConfigurationInterface_i::getPropertyDataSource(), RTT::removeProperty(), and RTT::corba::TaskContextProxy::synchronizeServices().

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 770 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.

Parameters
bagThe bag to list the properties of.
separatorThe token to separate properties in the path, Defaults to ".".

Definition at line 370 of file PropertyBag.cpp.

Referenced by RTT_corba_CConfigurationInterface_i::getPropertyList().

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.

Parameters
bagThe bag to list the property descriptions of.
separatorThe token to separate properties in the path, Defaults to ".".

Definition at line 377 of file PropertyBag.cpp.

Referenced by RTT_corba_CConfigurationInterface_i::getPropertyList().

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.

Parameters
targetThe bag in which the properties must be refreshed.
sourceThe bag containing new values for target.
strictSet 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 490 of file PropertyBag.cpp.

References RTT::Error, RTT::PropertyBag::find(), RTT::PropertyBag::getItem(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), RTT::base::PropertyBase::getType(), RTT::PropertyBag::getType(), RTT::PropertyBag::type, RTT::types::Types(), and RTT::updateOrRefreshProperty().

Referenced by RTT::types::BoostArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::CArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::StructTypeInfo< T, has_ostream >::composeTypeImpl(), RTT::marsh::PropertyLoader::load(), RTT::Property< T >::refresh(), and RTT::marsh::PropertyLoader::store().

RTT_API bool RTT::refreshProperty ( const PropertyBag target,
const base::PropertyBase source 
)

Refresh one Property in the target bag with the new value.

Parameters
targetThe bag in which a property with name source->getName() can be found.
sourceA property which contains a new value for a property with the same name in target.

Definition at line 527 of file PropertyBag.cpp.

References RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), and RTT::base::PropertyBase::refresh().

Referenced by RTT::refreshProperty(), and RTT::marsh::PropertyLoader::store().

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.

Parameters
targetThe bag in which the property exists and must be refreshed.
sourceThe bag containing prop as one of its children.
pathThe path to a property in source (or in a sub-bag of source), which must be created or updated in target.
separatorThe token to separate properties in the path,

Definition at line 683 of file PropertyBag.cpp.

References RTT::Debug, RTT::Error, RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), RTT::refreshProperty(), RTT::Property< T >::rvalue(), RTT::updateOrRefreshProperty(), 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().

See also
PropertyBag::removeProperty()
Examples:
/home/jenkins/workspace/rtt-doc/rtt/ConfigurationInterface.hpp.

Definition at line 416 of file PropertyBag.cpp.

References RTT::PropertyBag::find(), RTT::findProperty(), RTT::base::PropertyBase::ready(), RTT::PropertyBag::removeProperty(), and RTT::Property< T >::value().

Referenced by RTT::PropertyBag::addProperty(), and RTT::ConfigurationInterface::getConstant().

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().

See also
PropertyBag::ownProperty()

Definition at line 384 of file PropertyBag.cpp.

References RTT::Error, RTT::PropertyBag::find(), RTT::PropertyBag::ownProperty(), and RTT::Property< T >::value().

Referenced by RTT::corba::TaskContextProxy::synchronizeServices().

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.

Parameters
targetThe bag in which the properties must be updated.
sourceThe bag containing new values, descriptions or properties for target.

Definition at line 557 of file PropertyBag.cpp.

References RTT::types::TypeInfo::composeType(), RTT::base::PropertyBase::create(), RTT::Logger::Debug, RTT::Logger::endl(), RTT::Error, RTT::base::PropertyBase::getDataSource(), RTT::Property< T >::getDataSource(), RTT::base::PropertyBase::getDescription(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::getProperties(), RTT::PropertyBag::getType(), RTT::base::PropertyBase::getTypeInfo(), RTT::PropertyBag::list(), RTT::Logger::log(), RTT::PropertyBag::ownProperty(), RTT::PropertyBag::setType(), RTT::PropertyBag::type, RTT::types::Types(), RTT::base::PropertyBase::update(), RTT::updateOrRefreshProperty(), and RTT::Property< T >::value().

Referenced by RTT::marsh::PropertyLoader::load(), RTT::marsh::PropertyLoader::store(), and RTT::Property< T >::update().

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.

Parameters
targetThe bag in which the property must be updated.
sourceThe bag containing prop as one of its children.
pathThe path to a property in source (or in a sub-bag of source), which must be created or updated in target.
separatorThe token to separate properties in the path,

Definition at line 626 of file PropertyBag.cpp.

References RTT::base::PropertyBase::create(), RTT::Debug, RTT::Error, RTT::PropertyBag::find(), RTT::base::PropertyBase::getName(), RTT::PropertyBag::ownProperty(), RTT::Property< T >::rvalue(), RTT::updateOrRefreshProperty(), and RTT::Property< T >::value().

Referenced by RTT::marsh::PropertyLoader::store().