![]() |
RobWorkProject
23.9.11-
|
Container for a collection of Property Objects. More...
#include <PropertyMap.hpp>
Public Types | |
| typedef rw::core::Ptr< PropertyMap > | Ptr |
| smart pointer type to this class | |
| typedef std::function< void(PropertyMap *, rw::core::PropertyBase *)> | PropertyChangedListener |
| Method signature for a callback function. | |
| typedef MapType::const_iterator | iterator |
| Iterator for const PropertyBase::Ptr. | |
| typedef rw::core::iter_pair< iterator > | Range |
| Type for a range of properties. | |
Public Member Functions | |
| PropertyMap () | |
| Constructor. | |
| PropertyMap (std::string name) | |
| constructor More... | |
| ~PropertyMap () | |
| Destructor. | |
| PropertyMap (const PropertyMap &other) | |
| Copy constructor. | |
| PropertyMap & | operator= (const PropertyMap &other) |
| Assignment operator. | |
| void | swap (PropertyMap &other) |
| swap operator. | |
| void | clear () |
| Clear the content of the property map. | |
| const std::string & | getName () const |
| get the name of this propertymap More... | |
| template<class T > | |
| rw::core::Ptr< rw::core::Property< T > > | set (const std::string &identifier, const T &value) |
| Set the value of a property. More... | |
| template<typename T > | |
| rw::core::Ptr< rw::core::Property< T > > | add (const std::string &identifier, const std::string &description, const T &value) |
| Add a property to the map. If a property with the same identifier already exists then nothing is added/changed and the existing property is returned. More... | |
| template<typename T > | |
| rw::core::Ptr< rw::core::Property< T > > | addForce (const std::string &identifier, const std::string &description, const T &value) |
| Add a property to the map. If a property with the same identifier already exists then the value and description are changed and the existing property is returned. More... | |
| bool | add (rw::core::PropertyBase::Ptr property) |
| Adds a property to the map. More... | |
| template<class T > | |
| T * | getPtr (const std::string &identifier) |
| Get the value of a property or NULL if no such property. More... | |
| template<class T > | |
| const T * | getPtr (const std::string &identifier) const |
| Get the value of a property or NULL if no such property. More... | |
| template<class T > | |
| T & | get (const std::string &identifier) |
| Get the value of a property. More... | |
| template<class T > | |
| const T & | get (const std::string &identifier) const |
| Get the value of a property. More... | |
| template<class T > | |
| T & | get (const std::string &identifier, const T &defval) |
| Get the value of a property if it exists. More... | |
| template<class T > | |
| const T & | get (const std::string &identifier, const T &defval) const |
| Get the value of a property. More... | |
| bool | has (const std::string &identifier) const |
| True if a specific property exists. More... | |
| size_t | size () const |
| The number of properties. | |
| bool | empty () const |
| True iff the property map contains no properties. | |
| bool | erase (const std::string &identifier) |
| Remove a property. More... | |
| template<class T > | |
| rw::core::Ptr< rw::core::Property< T > > | findProperty (const std::string &identifier) const |
| Find the property for an identifier. More... | |
| rw::core::PropertyBase::Ptr | findPropertyBase (const std::string &identifier) |
| Find the property base for an identifier. More... | |
| const rw::core::PropertyBase::Ptr | findPropertyBase (const std::string &identifier) const |
| Find the property base for an identifier. More... | |
| void | addChangedListener (PropertyChangedListener callback) |
| Add listener to be call, when the property changes. More... | |
| void | clearChangedListeners () |
| Clears the list of changed listeners. | |
| void | notifyListeners (rw::core::PropertyBase *base=NULL) |
| Notifies listeners about a change in the Property. | |
| void | propertyChangedListener (rw::core::PropertyBase *base) |
| used for listening for property changes in the map More... | |
| Range | getProperties () const |
| Range of all PropertyBase* objects stored. More... | |
| template<> | |
| rw::core::Ptr< Property< rw::math::Q > > | findProperty (const std::string &identifier) const |
| Find the property for an identifier. More... | |
Container for a collection of Property Objects.
This container is used to bind various user information to for example Frame.
Example: Getting a string property with ID "Camera" from a frame
|
inline |
constructor
| name | [in] name of this propertymap |
|
inline |
Add a property to the map. If a property with the same identifier already exists then nothing is added/changed and the existing property is returned.
This will fire a PropertyChangedEvent (if a new property is added).
| identifier | [in] Property identifier. |
| description | [in] Property description. |
| value | [in] Property value. |
| bool add | ( | rw::core::PropertyBase::Ptr | property | ) |
Adds a property to the map.
This will fire a PropertyChangedEvent.
| property | [in] Property to add |
| void addChangedListener | ( | PropertyChangedListener | callback | ) |
Add listener to be call, when the property changes.
| callback | [in] Callback method |
|
inline |
Add a property to the map. If a property with the same identifier already exists then the value and description are changed and the existing property is returned.
This will fire a PropertyChangedEvent.
| identifier | [in] Property identifier. |
| description | [in] Property description. |
| value | [in] Property value. |
| bool erase | ( | const std::string & | identifier | ) |
Remove a property.
|
inline |
Find the property for an identifier.
The method finds the Property<T> object having a given identifier. If no property with that identifier exists or if the value of the property is not of type T then NULL is returned.
| identifier | [in] property identifier |
| rw::core::Ptr<Property<rw::math::Q> > findProperty | ( | const std::string & | identifier | ) | const |
Find the property for an identifier.
The method finds the Property<T> object having a given identifier. If no property with that identifier exists or if the value of the property is not of type T then NULL is returned.
| identifier | [in] property identifier |
| rw::core::PropertyBase::Ptr findPropertyBase | ( | const std::string & | identifier | ) |
Find the property base for an identifier.
The find methods returns pointer to PropertyBase object or NULL if a property base with that identifier does not exist.
| identifier | [in] identifier for the property base to find. |
| const rw::core::PropertyBase::Ptr findPropertyBase | ( | const std::string & | identifier | ) | const |
Find the property base for an identifier.
The find methods returns pointer to PropertyBase object or NULL if a property base with that identifier does not exist.
| identifier | [in] identifier for the property base to find. |
|
inline |
Get the value of a property.
If a property of the given identifier and type cannot be found, the method throws an exception
| identifier | [in] the identifier of the property |
|
inline |
Get the value of a property.
If a property of the given identifier and type cannot be found, the method throws an exception
| identifier | [in] the identifier of the property |
|
inline |
Get the value of a property if it exists.
If a property of the given identifier and type cannot be found, the method returns the default value defval.
example int iterations = map.get<int>("Iterations", 20);
This will fire a PropertyChangedEvent if a new property is added. Notice that a new property is inserted in the map with the default value if it does not already exist.
| identifier | [in] the identifier of the property |
| defval | [in] the value that will be returned if property with identifier is not found. |
|
inline |
Get the value of a property.
If a property of the given identifier and type cannot be found method throws an exception
example int iterations = map.get<int>("Iterations", 20);
| identifier | [in] the identifier of the property |
| defval | [in] the value that will be returned if property with identifier is not found. |
|
inline |
get the name of this propertymap
| Range getProperties | ( | ) | const |
Range of all PropertyBase* objects stored.
Note that this low-level interface does permits the PropertyBase values to be modified even though the method itself is declared const.
|
inline |
Get the value of a property or NULL if no such property.
If a property of the given identifier and type cannot be found, the method returns NULL.
| identifier | [in] the identifier of the property |
|
inline |
Get the value of a property or NULL if no such property.
If a property of the given identifier and type cannot be found, the method returns NULL.
| identifier | [in] the identifier of the property |
| bool has | ( | const std::string & | identifier | ) | const |
True if a specific property exists.
| identifier | [in] The identifier of the property |
| void propertyChangedListener | ( | rw::core::PropertyBase * | base | ) |
used for listening for property changes in the map
| base |
|
inline |
Set the value of a property.
If a property with the given identifier cannot be found, a new property with no description is created and inserted.
This will fire a PropertyChangedEvent.
| identifier | [in] the property identifier |
| value | [in] the new value |