Orocos Real-Time Toolkit
2.9.0
|
A container for holding references to properties. More...
#include <rtt/PropertyBag.hpp>
Classes | |
struct | FindPropType |
A function object for finding a Property by name and type. More... | |
Public Types | |
typedef std::vector< base::PropertyBase * > | Properties |
The container in which the properties are stored. More... | |
typedef Properties | PropertyContainerType |
Deprecated, use Properties. More... | |
typedef Properties::iterator | iterator |
An iterator over the Properties. More... | |
typedef Properties::const_iterator | const_iterator |
A const iterator over the Properties. More... | |
typedef std::vector< std::string > | Names |
The container to hold names of Properties. More... | |
Public Member Functions | |
PropertyBag () | |
The default constructor. More... | |
PropertyBag (const std::string &_type) | |
The typed constructor. More... | |
PropertyBag (const PropertyBag &orig) | |
The copy constructor. More... | |
~PropertyBag () | |
Destroy this object and destroy all owned properties. More... | |
void | add (base::PropertyBase *p) |
Add a valid property to the container. More... | |
void | remove (base::PropertyBase *p) |
Remove a property from the container. More... | |
template<class T > | |
Property< T > & | addProperty (const std::string &name, T &attr) |
Adds a variable of any type as a property to this bag. More... | |
bool | addProperty (base::PropertyBase &p) |
Add a valid property to the container. More... | |
bool | removeProperty (base::PropertyBase *p) |
Remove a property from the container. More... | |
bool | ownProperty (base::PropertyBase *p) |
Set a property to be owned by this bag. More... | |
bool | ownsProperty (base::PropertyBase *p) const |
Returns true if this property is owned by this Bag. More... | |
void | clear () |
Removes all PropertyBases from this bag, without deleting them. More... | |
void | list (Names &names) const |
List the names of all properties. More... | |
Names | list () const |
List the names of all properties. More... | |
bool | empty () const |
Return true if no properties are present in this bag. More... | |
base::PropertyBase * | getProperty (const std::string &name) const |
Get a Property with name name. More... | |
template<class T > | |
Property< T > * | getPropertyType (const std::string &name) const |
Get the first Property with name name of a given type T. More... | |
base::PropertyBase * | getItem (int i) const |
Returns the i'th Property, starting from 0. More... | |
size_t | size () const |
Get the number of Properties in this bag. More... | |
void | identify (base::PropertyIntrospection *pi) const |
Identify the contents of this bag through introspection. More... | |
void | identify (base::PropertyBagVisitor *pi) const |
Identify the contents of this bag through introspection. More... | |
base::PropertyBase * | find (const std::string &name) const |
Find the base::PropertyBase with name name. More... | |
template<class T > | |
base::PropertyBase * | findValue (const T &value) const |
Finds the base::PropertyBase by value. More... | |
PropertyBag & | operator= (const PropertyBag &orig) |
This assignment assigns all PropertyBases of another bag in this bag, making an exact copy or the original. More... | |
PropertyBag & | operator<<= (const PropertyBag &source) |
The update operator. More... | |
PropertyBag & | operator<< (base::PropertyBase *item) |
The 'add' operator. More... | |
const std::string & | getType () const |
void | setType (const std::string &newtype) |
Properties & | getProperties () |
Returns a list of all the property objects in this bag. More... | |
const Properties & | getProperties () const |
Returns a list of all the property objects in this bag. More... | |
Properties | getProperties (const std::string &name) const |
Returns a list of all property objects with the name name. More... | |
Names | getPropertyNames () const |
Returns a list of all the names of the properties in this bag. More... | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
Protected Attributes | |
Properties | mproperties |
Properties | mowned_props |
std::string | type |
A container for holding references to properties.
This class groups properties of different types into a single container. A PropertyBag object can handed to a marsh::Marshaller object which will serialize the contents of the PropertyBag.
All operations on a PropertyBag are non recursive. The PropertyBag itself is not aware of the possible hierarchical structure. You need to use the global scope functions for handling hierarchical structures.
A PropertyBag is not the owner of the properties within. It defines a group of properties, nothing more. When this group of properties contains another PropertyBag, this bag is considered as a 'pointer' to other properties. Even such a bag is not owned by the PropertyBag.
It can happen in an application that a PropertyBag is filled with dynamically created Property objects. The bag is not responsible for cleaning up these objects once they are no longer needed. The application which uses the PropertyBag has to find a way of deleting the possible dangling pointers.
To add a Property<ClassT> prop to a PropertyBag bag, use
bag.add(&prop).
To retrieve this property, either use find or getProperty to retrieve a Property by name :
base::PropertyBase* pb = bag.find( "name" ). Property<ClassT> pb = bag.getProperty( "name" ).
Both will return null if no such property exists.
Definition at line 96 of file PropertyBag.hpp.
typedef Properties::const_iterator RTT::PropertyBag::const_iterator |
A const iterator over the Properties.
Definition at line 114 of file PropertyBag.hpp.
typedef Properties::iterator RTT::PropertyBag::iterator |
An iterator over the Properties.
Definition at line 110 of file PropertyBag.hpp.
typedef std::vector<std::string> RTT::PropertyBag::Names |
The container to hold names of Properties.
Definition at line 119 of file PropertyBag.hpp.
typedef std::vector<base::PropertyBase*> RTT::PropertyBag::Properties |
The container in which the properties are stored.
Definition at line 102 of file PropertyBag.hpp.
Deprecated, use Properties.
Definition at line 106 of file PropertyBag.hpp.
RTT::PropertyBag::PropertyBag | ( | ) |
The default constructor.
Definition at line 54 of file PropertyBag.cpp.
RTT::PropertyBag::PropertyBag | ( | const std::string & | _type | ) |
The typed constructor.
type | The type of PropertyBag. |
Definition at line 58 of file PropertyBag.cpp.
RTT::PropertyBag::PropertyBag | ( | const PropertyBag & | orig | ) |
The copy constructor.
The copy constructor of the PropertyBag makes non-deep copies of its elements.
Definition at line 62 of file PropertyBag.cpp.
RTT::PropertyBag::~PropertyBag | ( | ) |
Destroy this object and destroy all owned properties.
Definition at line 68 of file PropertyBag.cpp.
References clear().
void RTT::PropertyBag::add | ( | base::PropertyBase * | p | ) |
Add a valid property to the container.
Analogous to addProperty.
p | Pointer to the property to be added. |
Definition at line 73 of file PropertyBag.cpp.
References addProperty().
Referenced by RTT::flattenPropertyBag(), RTT::marsh::PropertyBagIntrospector::introspect(), operator<<=(), operator=(), and RTT::types::typeDecomposition().
|
inline |
Adds a variable of any type as a property to this bag.
A Property is created which causes contents of the property always to be in sync with the contents of attr.
name | The name of this property |
attr | The variable that will be aliased. |
Definition at line 166 of file PropertyBag.hpp.
References RTT::removeProperty().
Referenced by add().
bool RTT::PropertyBag::addProperty | ( | base::PropertyBase & | p | ) |
Add a valid property to the container.
p | Pointer to the property to be added. |
Definition at line 105 of file PropertyBag.cpp.
References mproperties, and RTT::base::PropertyBase::ready().
|
inline |
Definition at line 353 of file PropertyBag.hpp.
Referenced by RTT::types::composePropertyBag(), and RTT::types::decomposePropertyBag().
|
inline |
Definition at line 354 of file PropertyBag.hpp.
void RTT::PropertyBag::clear | ( | ) |
Removes all PropertyBases from this bag, without deleting them.
This is a not recursive function.
Definition at line 132 of file PropertyBag.cpp.
References mowned_props, and mproperties.
Referenced by RTT::deleteProperties(), RTT::deletePropertyBag(), operator=(), and ~PropertyBag().
|
inline |
Return true if no properties are present in this bag.
Definition at line 219 of file PropertyBag.hpp.
Referenced by RTT::types::composePropertyBag(), RTT::types::decomposePropertyBag(), and RTT::types::typeDecomposition().
|
inline |
Definition at line 355 of file PropertyBag.hpp.
Referenced by RTT::types::composePropertyBag(), and RTT::types::decomposePropertyBag().
|
inline |
Definition at line 356 of file PropertyBag.hpp.
PropertyBase * RTT::PropertyBag::find | ( | const std::string & | name | ) | const |
Find the base::PropertyBase with name name.
This function returns the first match.
name | The name of the property to search for. |
Definition at line 210 of file PropertyBag.cpp.
References mproperties.
Referenced by RTT::extras::composeProperty(), RTT::findProperty(), operator<<=(), RTT::refreshProperties(), RTT::refreshProperty(), RTT::removeProperty(), RTT::scripting::PropertyParser::reset(), RTT::storeProperty(), RTT::updateProperty(), and RTT::scripting::ValueParser::ValueParser().
|
inline |
Finds the base::PropertyBase by value.
This function returns the first match.
value | The value the Property should have |
T | The data type of the value. |
Definition at line 295 of file PropertyBag.hpp.
References RTT::base::PropertyBase::ready(), and RTT::Property< T >::value().
|
inline |
Returns the i'th Property, starting from 0.
Definition at line 254 of file PropertyBag.hpp.
Referenced by RTT::types::composeTemplateProperty(), RTT::operator<<(), and RTT::refreshProperties().
|
inline |
Returns a list of all the property objects in this bag.
Definition at line 336 of file PropertyBag.hpp.
Referenced by RTT::copyProperties(), RTT::deleteProperties(), RTT::deletePropertyBag(), RTT::StatementProcessor::D::doPrint(), RTT::findProperty(), RTT::flattenPropertyBag(), operator<<=(), RTT::refreshProperties(), RTT::marsh::XMLRPCMarshaller< output_stream >::serialize(), and RTT::updateProperties().
|
inline |
Returns a list of all the property objects in this bag.
Definition at line 341 of file PropertyBag.hpp.
PropertyBag::Properties RTT::PropertyBag::getProperties | ( | const std::string & | name | ) | const |
Returns a list of all property objects with the name name.
Definition at line 166 of file PropertyBag.cpp.
References mproperties.
base::PropertyBase * RTT::PropertyBag::getProperty | ( | const std::string & | name | ) | const |
Get a Property with name name.
name | The name of the property to search for. |
Definition at line 218 of file PropertyBag.cpp.
References mproperties.
|
inline |
Returns a list of all the names of the properties in this bag.
Definition at line 351 of file PropertyBag.hpp.
|
inline |
Get the first Property with name name of a given type T.
name | The name of the property to search for. |
T | The data type of the property. |
Definition at line 242 of file PropertyBag.hpp.
|
inline |
Definition at line 329 of file PropertyBag.hpp.
Referenced by RTT::types::composeTemplateProperty(), 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(), operator<<=(), operator=(), RTT::refreshProperties(), and RTT::updateProperties().
void RTT::PropertyBag::identify | ( | base::PropertyIntrospection * | pi | ) | const |
Identify the contents of this bag through introspection.
Definition at line 180 of file PropertyBag.cpp.
References mproperties.
Referenced by RTT::marsh::PropertyBagIntrospector::introspect().
void RTT::PropertyBag::identify | ( | base::PropertyBagVisitor * | pi | ) | const |
Identify the contents of this bag through introspection.
Definition at line 190 of file PropertyBag.cpp.
References RTT::base::PropertyBase::getName(), and mproperties.
void RTT::PropertyBag::list | ( | Names & | names | ) | const |
List the names of all properties.
names | The container which will be used to store all available property names in. |
Definition at line 144 of file PropertyBag.cpp.
References mproperties.
Referenced by RTT::updateProperties().
std::vector< std::string > RTT::PropertyBag::list | ( | ) | const |
List the names of all properties.
Definition at line 154 of file PropertyBag.cpp.
References mproperties.
|
inline |
The 'add' operator.
Equivalent to add().
item | The Property to add to this bag. |
Definition at line 327 of file PropertyBag.hpp.
PropertyBag & RTT::PropertyBag::operator<<= | ( | const PropertyBag & | source | ) |
The update operator.
It updates this bag so it contains all PropertyBases of another bag, removing own PropertyBases if duplicate names exist in the source bag.
Definition at line 247 of file PropertyBag.cpp.
References add(), find(), getProperties(), getType(), and setType().
PropertyBag & RTT::PropertyBag::operator= | ( | const PropertyBag & | orig | ) |
This assignment assigns all PropertyBases of another bag in this bag, making an exact copy or the original.
Definition at line 227 of file PropertyBag.cpp.
References add(), clear(), RTT::base::PropertyBase::create(), getType(), mproperties, ownProperty(), ownsProperty(), and setType().
bool RTT::PropertyBag::ownProperty | ( | base::PropertyBase * | p | ) |
Set a property to be owned by this bag.
Definition at line 83 of file PropertyBag.cpp.
References mowned_props, mproperties, RTT::base::PropertyBase::ready(), and removeProperty().
Referenced by RTT::types::composePropertyBag(), RTT::copyProperties(), RTT::types::decomposePropertyBag(), operator=(), RTT::storeProperty(), RTT::types::typeDecomposition(), RTT::updateProperties(), and RTT::updateProperty().
bool RTT::PropertyBag::ownsProperty | ( | base::PropertyBase * | p | ) | const |
Returns true if this property is owned by this Bag.
Definition at line 95 of file PropertyBag.cpp.
References mowned_props.
Referenced by RTT::deleteProperties(), RTT::deletePropertyBag(), and operator=().
void RTT::PropertyBag::remove | ( | base::PropertyBase * | p | ) |
Remove a property from the container.
Analogous to removeProperty.
p | Pointer to the property to be removed. |
Definition at line 78 of file PropertyBag.cpp.
References removeProperty().
bool RTT::PropertyBag::removeProperty | ( | base::PropertyBase * | p | ) |
Remove a property from the container.
p | Pointer to the property to be removed. |
Definition at line 115 of file PropertyBag.cpp.
References mowned_props, and mproperties.
Referenced by ownProperty(), remove(), and RTT::removeProperty().
|
inline |
Definition at line 331 of file PropertyBag.hpp.
Referenced by operator<<=(), operator=(), RTT::types::typeDecomposition(), and RTT::updateProperties().
|
inline |
Get the number of Properties in this bag.
Definition at line 264 of file PropertyBag.hpp.
Referenced by RTT::types::composeTemplateProperty(), RTT::types::BoostArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::CArrayTypeInfo< T, has_ostream >::composeType(), and RTT::operator<<().
|
protected |
Definition at line 359 of file PropertyBag.hpp.
Referenced by clear(), ownProperty(), ownsProperty(), and removeProperty().
|
protected |
Definition at line 358 of file PropertyBag.hpp.
Referenced by addProperty(), clear(), find(), getProperties(), getProperty(), identify(), list(), operator=(), ownProperty(), and removeProperty().
|
protected |
Definition at line 370 of file PropertyBag.hpp.
Referenced by RTT::refreshProperties(), and RTT::updateProperties().