#include <rtt/PropertyBag.hpp>
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.
bag.add(&prop).
PropertyBase* pb = bag.find( "name" ).
Property<ClassT> pb = bag.getProperty<ClassT>( "name" ).
Definition at line 98 of file PropertyBag.hpp.
Public Types | |
|
typedef std::vector < PropertyBase * > | Properties |
| The container in which the properties are stored. | |
| typedef Properties | PropertyContainerType |
| Deprecated, use Properties. | |
|
typedef Properties::iterator | iterator |
| An iterator over the Properties. | |
|
typedef Properties::const_iterator | const_iterator |
| A const iterator over the Properties. | |
|
typedef std::vector < std::string > | Names |
| The container to hold names of Properties. | |
Public Member Functions | |
| PropertyBag () | |
| The default constructor. | |
| PropertyBag (const std::string &_type) | |
| The typed constructor. | |
| PropertyBag (const PropertyBag &orig) | |
| void | add (PropertyBase *p) |
| Add a valid property to the container. | |
| void | remove (PropertyBase *p) |
| Remove a property from the container. | |
| bool | addProperty (PropertyBase *p) |
| Add a valid property to the container. | |
| bool | removeProperty (PropertyBase *p) |
| Remove a property from the container. | |
| void | clear () |
| Removes all PropertyBases from this bag, without deleting them. | |
| void | list (Names &names) const |
| List the names of all properties. | |
| Names | list () const |
| List the names of all properties. | |
| bool | empty () const |
| Return true if no properties are present in this bag. | |
| template<class T> | |
| Property< T > * | getProperty (const std::string &name) const |
| Get a Property<T> with name name. | |
| PropertyBase * | getItem (int i) const |
| Returns the i'th Property, starting from 0. | |
| size_t | size () const |
| Get the number of Properties in this bag. | |
| void | identify (PropertyIntrospection *pi) const |
| Identify the contents of this bag through introspection. | |
| void | identify (PropertyBagVisitor *pi) const |
| Identify the contents of this bag through introspection. | |
| PropertyBase * | find (const std::string &name) const |
| Find the PropertyBase with name name. | |
| PropertyBag & | operator= (const PropertyBag &orig) |
| This assignment assigns all PropertyBases of another bag in this bag, making an exact copy or the original. | |
| PropertyBag & | operator<<= (const PropertyBag &source) |
| The update operator. | |
| PropertyBag & | operator<< (PropertyBase *item) |
| The 'add' operator. | |
| const std::string & | getType () const |
| void | setType (const std::string &newtype) |
| Properties & | getProperties () |
| Returns a list of all the property objects in this bag. | |
| const Properties & | getProperties () const |
| Returns a list of all the property objects in this bag. | |
| Names | getPropertyNames () const |
| Returns a list of all the names of the properties in this bag. | |
| iterator | begin () |
| const_iterator | begin () const |
| iterator | end () |
| const_iterator | end () const |
Protected Attributes | |
| Properties | mproperties |
| std::string | type |
Classes | |
| struct | FindProp |
| A function object for finding a Property by name. More... | |
| PropertyBag | ( | const std::string & | _type | ) |
The typed constructor.
| type | The type of PropertyBag. |
Definition at line 52 of file PropertyBag.cpp.
| PropertyBag | ( | const PropertyBag & | orig | ) |
The copy constructor. The copy constructor of the PropertyBag makes non-deep copies of its elements.
Definition at line 56 of file PropertyBag.cpp.
| void add | ( | PropertyBase * | p | ) |
Add a valid property to the container.
Analogous to addProperty.
| p | Pointer to the property to be added. |
Definition at line 61 of file PropertyBag.cpp.
References PropertyBag::addProperty().
Referenced by AttributeRepository::addProperty(), RTT::copyProperties(), RTT::decomposeProperty(), SimpleDemarshaller::deserialize(), SAX2XMLRPCHandler::endElement(), RTT::flattenPropertyBag(), PropertyBagIntrospector::introspect(), AnyConversion< PropertyBag >::update(), and RTT::updateProperties().
| void remove | ( | PropertyBase * | p | ) |
Remove a property from the container.
Analogous to removeProperty.
| p | Pointer to the property to be removed. |
Definition at line 66 of file PropertyBag.cpp.
References PropertyBag::removeProperty().
Referenced by AttributeRepository::removeProperty().
| bool addProperty | ( | PropertyBase * | p | ) |
Add a valid property to the container.
| p | Pointer to the property to be added. |
Definition at line 71 of file PropertyBag.cpp.
References PropertyBag::mproperties, and PropertyBase::ready().
Referenced by PropertyBag::add(), and RTT::updateProperty().
| bool removeProperty | ( | PropertyBase * | p | ) |
Remove a property from the container.
| p | Pointer to the property to be removed. |
Definition at line 79 of file PropertyBag.cpp.
References PropertyBag::mproperties.
Referenced by PropertyBag::remove().
| void clear | ( | ) |
Removes all PropertyBases from this bag, without deleting them.
This is a not recursive function.
Definition at line 91 of file PropertyBag.cpp.
References PropertyBag::mproperties.
Referenced by TaskContext::clear(), RTT::deleteProperties(), and RTT::deletePropertyBag().
| void 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 96 of file PropertyBag.cpp.
References PropertyBag::mproperties.
| std::vector< std::string > list | ( | ) | const |
List the names of all properties.
Definition at line 107 of file PropertyBag.cpp.
References PropertyBag::mproperties.
| Property<T>* getProperty | ( | const std::string & | name | ) | const [inline] |
Get a Property<T> with name name.
| T | The type of which this property is. | |
| name | The name of the property to search for. |
Definition at line 202 of file PropertyBag.hpp.
| PropertyBase* getItem | ( | int | i | ) | const [inline] |
Returns the i'th Property, starting from 0.
Definition at line 214 of file PropertyBag.hpp.
Referenced by RTT::composeProperty(), RTT::refreshProperties(), and RTT::updateProperties().
| PropertyBase * find | ( | const std::string & | name | ) | const |
Find the PropertyBase with name name.
| name | The name of the property to search for. |
Definition at line 140 of file PropertyBag.cpp.
References PropertyBag::mproperties.
Referenced by AttributeRepository::addProperty(), RTT::composeProperty(), RTT::findProperty(), AttributeRepository::hasProperty(), PropertyBag::operator<<=(), RTT::refreshProperties(), RTT::refreshProperty(), AttributeRepository::removeProperty(), AnyConversion< PropertyBag >::update(), RTT::updateProperties(), and RTT::updateProperty().
| 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 162 of file PropertyBag.cpp.
References PropertyBag::find(), PropertyBag::getProperties(), PropertyBag::getType(), and PropertyBag::setType().
| PropertyBag& operator<< | ( | PropertyBase * | item | ) | [inline] |
The 'add' operator.
Equivalent to add().
| item | The Property to add to this bag. |
Definition at line 265 of file PropertyBag.hpp.
1.5.3