RTT::PropertyBag Class Reference
[Property Interface]

A container for holding references to properties. More...

#include <PropertyBag.hpp>

List of all members.

Classes

struct  FindPropType

Public Types

typedef Properties::const_iterator const_iterator
typedef Properties::const_iterator const_iterator
typedef Properties::iterator iterator
typedef Properties::iterator iterator
typedef std::vector< std::string > Names
typedef std::vector< std::string > Names
typedef std::vector
< base::PropertyBase * > 
Properties
typedef std::vector
< base::PropertyBase * > 
Properties
typedef Properties PropertyContainerType
typedef Properties PropertyContainerType

Public Member Functions

void add (base::PropertyBase *p)
void add (base::PropertyBase *p)
bool addProperty (base::PropertyBase &p)
template<class T >
Property< T > & addProperty (const std::string &name, T &attr)
bool addProperty (base::PropertyBase &p)
template<class T >
Property< T > & addProperty (const std::string &name, T &attr)
const_iterator begin () const
iterator begin ()
const_iterator begin () const
iterator begin ()
void clear ()
void clear ()
bool empty () const
bool empty () const
const_iterator end () const
iterator end ()
const_iterator end () const
iterator end ()
base::PropertyBasefind (const std::string &name) const
base::PropertyBasefind (const std::string &name) const
template<class T >
base::PropertyBasefindValue (const T &value) const
template<class T >
base::PropertyBasefindValue (const T &value) const
base::PropertyBasegetItem (int i) const
base::PropertyBasegetItem (int i) const
Properties getProperties (const std::string &name) const
const PropertiesgetProperties () const
PropertiesgetProperties ()
Properties getProperties (const std::string &name) const
const PropertiesgetProperties () const
PropertiesgetProperties ()
base::PropertyBasegetProperty (const std::string &name) const
base::PropertyBasegetProperty (const std::string &name) const
Names getPropertyNames () const
Names getPropertyNames () const
template<class T >
Property< T > * getPropertyType (const std::string &name) const
template<class T >
Property< T > * getPropertyType (const std::string &name) const
const std::string & getType () const
const std::string & getType () const
void identify (base::PropertyBagVisitor *pi) const
void identify (base::PropertyIntrospection *pi) const
void identify (base::PropertyBagVisitor *pi) const
void identify (base::PropertyIntrospection *pi) const
Names list () const
void list (Names &names) const
Names list () const
void list (Names &names) const
PropertyBagoperator<< (base::PropertyBase *item)
PropertyBagoperator<< (base::PropertyBase *item)
PropertyBagoperator<<= (const PropertyBag &source)
PropertyBagoperator<<= (const PropertyBag &source)
PropertyBagoperator= (const PropertyBag &orig)
PropertyBagoperator= (const PropertyBag &orig)
bool ownProperty (base::PropertyBase *p)
bool ownProperty (base::PropertyBase *p)
bool ownsProperty (base::PropertyBase *p) const
bool ownsProperty (base::PropertyBase *p) const
 PropertyBag (const PropertyBag &orig)
 The copy constructor. The copy constructor of the PropertyBag makes non-deep copies of its elements.
 PropertyBag (const std::string &_type)
 PropertyBag ()
 PropertyBag (const PropertyBag &orig)
 The copy constructor. The copy constructor of the PropertyBag makes non-deep copies of its elements.
 PropertyBag (const std::string &_type)
 PropertyBag ()
void remove (base::PropertyBase *p)
void remove (base::PropertyBase *p)
bool removeProperty (base::PropertyBase *p)
bool removeProperty (base::PropertyBase *p)
void setType (const std::string &newtype)
void setType (const std::string &newtype)
size_t size () const
size_t size () const
 ~PropertyBag ()
 ~PropertyBag ()

Protected Attributes

Properties mowned_props
Properties mproperties
std::string type

Detailed Description

A container for holding references to properties.

Introduction

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.

Constructing PropertyBags

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.

Warning:
The elements in a PropertyBag are unordered. Operations on the bag may change the relative order of the elements.

Using PropertyBags

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.

See also:
base::PropertyBase, Property, Recursive Property Bag Operations.

Definition at line 96 of file install/include/rtt/PropertyBag.hpp.


Member Typedef Documentation

typedef Properties::const_iterator RTT::PropertyBag::const_iterator

A const iterator over the Properties.

Definition at line 114 of file rtt/PropertyBag.hpp.

typedef Properties::const_iterator RTT::PropertyBag::const_iterator

A const iterator over the Properties.

Definition at line 114 of file install/include/rtt/PropertyBag.hpp.

typedef Properties::iterator RTT::PropertyBag::iterator

An iterator over the Properties.

Definition at line 110 of file rtt/PropertyBag.hpp.

typedef Properties::iterator RTT::PropertyBag::iterator

An iterator over the Properties.

Definition at line 110 of file install/include/rtt/PropertyBag.hpp.

typedef std::vector<std::string> RTT::PropertyBag::Names

The container to hold names of Properties.

Definition at line 119 of file rtt/PropertyBag.hpp.

typedef std::vector<std::string> RTT::PropertyBag::Names

The container to hold names of Properties.

Definition at line 119 of file install/include/rtt/PropertyBag.hpp.

The container in which the properties are stored.

Definition at line 102 of file rtt/PropertyBag.hpp.

The container in which the properties are stored.

Definition at line 102 of file install/include/rtt/PropertyBag.hpp.

Deprecated, use Properties.

Definition at line 106 of file rtt/PropertyBag.hpp.

Deprecated, use Properties.

Definition at line 106 of file install/include/rtt/PropertyBag.hpp.


Constructor & Destructor Documentation

RTT::PropertyBag::PropertyBag (  ) 

The default constructor.

Definition at line 54 of file PropertyBag.cpp.

RTT::PropertyBag::PropertyBag ( const std::string &  _type  ) 

The typed constructor.

Parameters:
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 75 of file PropertyBag.cpp.

RTT::PropertyBag::PropertyBag (  ) 

The default constructor.

RTT::PropertyBag::PropertyBag ( const std::string &  _type  ) 

The typed constructor.

Parameters:
type The type of PropertyBag.
RTT::PropertyBag::PropertyBag ( const PropertyBag orig  ) 

The copy constructor. The copy constructor of the PropertyBag makes non-deep copies of its elements.

RTT::PropertyBag::~PropertyBag (  ) 

Destroy this object and destroy all owned properties.


Member Function Documentation

void RTT::PropertyBag::add ( base::PropertyBase p  ) 

Add a valid property to the container. Analogous to addProperty.

Parameters:
p Pointer to the property to be added.
void RTT::PropertyBag::add ( base::PropertyBase p  ) 

Add a valid property to the container. Analogous to addProperty.

Parameters:
p Pointer to the property to be added.

Definition at line 80 of file PropertyBag.cpp.

bool RTT::PropertyBag::addProperty ( base::PropertyBase p  ) 

Add a valid property to the container.

Parameters:
p Pointer to the property to be added.
Returns:
false if !p || !p->ready(), true otherwise.
template<class T >
Property<T>& RTT::PropertyBag::addProperty ( const std::string &  name,
T &  attr 
) [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.

Parameters:
name The name of this property
attr The variable that will be aliased.
Returns:
the Property object by reference, which you can further query or document.

Definition at line 166 of file rtt/PropertyBag.hpp.

bool RTT::PropertyBag::addProperty ( base::PropertyBase p  ) 

Add a valid property to the container.

Parameters:
p Pointer to the property to be added.
Returns:
false if !p || !p->ready(), true otherwise.

Definition at line 112 of file PropertyBag.cpp.

template<class T >
Property<T>& RTT::PropertyBag::addProperty ( const std::string &  name,
T &  attr 
) [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.

Parameters:
name The name of this property
attr The variable that will be aliased.
Returns:
the Property object by reference, which you can further query or document.

Definition at line 166 of file install/include/rtt/PropertyBag.hpp.

const_iterator RTT::PropertyBag::begin (  )  const [inline]

Definition at line 354 of file rtt/PropertyBag.hpp.

iterator RTT::PropertyBag::begin (  )  [inline]

Definition at line 353 of file rtt/PropertyBag.hpp.

const_iterator RTT::PropertyBag::begin (  )  const [inline]

Definition at line 354 of file install/include/rtt/PropertyBag.hpp.

iterator RTT::PropertyBag::begin (  )  [inline]

Definition at line 353 of file install/include/rtt/PropertyBag.hpp.

void RTT::PropertyBag::clear (  ) 

Removes all PropertyBases from this bag, without deleting them. This is a not recursive function.

void RTT::PropertyBag::clear (  ) 

Removes all PropertyBases from this bag, without deleting them. This is a not recursive function.

Definition at line 139 of file PropertyBag.cpp.

bool RTT::PropertyBag::empty (  )  const [inline]

Return true if no properties are present in this bag.

Definition at line 219 of file rtt/PropertyBag.hpp.

bool RTT::PropertyBag::empty (  )  const [inline]

Return true if no properties are present in this bag.

Definition at line 219 of file install/include/rtt/PropertyBag.hpp.

const_iterator RTT::PropertyBag::end (  )  const [inline]

Definition at line 356 of file rtt/PropertyBag.hpp.

iterator RTT::PropertyBag::end (  )  [inline]

Definition at line 355 of file rtt/PropertyBag.hpp.

const_iterator RTT::PropertyBag::end (  )  const [inline]

Definition at line 356 of file install/include/rtt/PropertyBag.hpp.

iterator RTT::PropertyBag::end (  )  [inline]

Definition at line 355 of file install/include/rtt/PropertyBag.hpp.

base::PropertyBase* RTT::PropertyBag::find ( const std::string &  name  )  const

Find the base::PropertyBase with name name. This function returns the first match.

Parameters:
name The name of the property to search for.
Returns:
The base::PropertyBase with this name, zero if it does not exist.
PropertyBase * RTT::PropertyBag::find ( const std::string &  name  )  const

Find the base::PropertyBase with name name. This function returns the first match.

Parameters:
name The name of the property to search for.
Returns:
The base::PropertyBase with this name, zero if it does not exist.

Definition at line 217 of file PropertyBag.cpp.

template<class T >
base::PropertyBase* RTT::PropertyBag::findValue ( const T &  value  )  const [inline]

Finds the base::PropertyBase by value. This function returns the first match.

Parameters:
value The value the Property should have
T The data type of the value.
Returns:
a pointer to the property or zero if not found.

Definition at line 295 of file rtt/PropertyBag.hpp.

template<class T >
base::PropertyBase* RTT::PropertyBag::findValue ( const T &  value  )  const [inline]

Finds the base::PropertyBase by value. This function returns the first match.

Parameters:
value The value the Property should have
T The data type of the value.
Returns:
a pointer to the property or zero if not found.

Definition at line 295 of file install/include/rtt/PropertyBag.hpp.

base::PropertyBase* RTT::PropertyBag::getItem ( int  i  )  const [inline]

Returns the i'th Property, starting from 0.

Returns:
zero if i is out of range.

Definition at line 254 of file rtt/PropertyBag.hpp.

base::PropertyBase* RTT::PropertyBag::getItem ( int  i  )  const [inline]

Returns the i'th Property, starting from 0.

Returns:
zero if i is out of range.

Definition at line 254 of file install/include/rtt/PropertyBag.hpp.

Properties RTT::PropertyBag::getProperties ( const std::string &  name  )  const

Returns a list of all property objects with the name name.

const Properties& RTT::PropertyBag::getProperties (  )  const [inline]

Returns a list of all the property objects in this bag.

Definition at line 341 of file rtt/PropertyBag.hpp.

Properties& RTT::PropertyBag::getProperties (  )  [inline]

Returns a list of all the property objects in this bag.

Definition at line 336 of file rtt/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 173 of file PropertyBag.cpp.

const Properties& RTT::PropertyBag::getProperties (  )  const [inline]

Returns a list of all the property objects in this bag.

Definition at line 341 of file install/include/rtt/PropertyBag.hpp.

Properties& RTT::PropertyBag::getProperties (  )  [inline]

Returns a list of all the property objects in this bag.

Definition at line 336 of file install/include/rtt/PropertyBag.hpp.

base::PropertyBase* RTT::PropertyBag::getProperty ( const std::string &  name  )  const

Get a Property with name name.

Parameters:
name The name of the property to search for.
Returns:
The PropertyBase with this name, zero if it does not exist.
base::PropertyBase * RTT::PropertyBag::getProperty ( const std::string &  name  )  const

Get a Property with name name.

Parameters:
name The name of the property to search for.
Returns:
The PropertyBase with this name, zero if it does not exist.

Definition at line 225 of file PropertyBag.cpp.

Names RTT::PropertyBag::getPropertyNames (  )  const [inline]

Returns a list of all the names of the properties in this bag.

Definition at line 351 of file rtt/PropertyBag.hpp.

Names RTT::PropertyBag::getPropertyNames (  )  const [inline]

Returns a list of all the names of the properties in this bag.

Definition at line 351 of file install/include/rtt/PropertyBag.hpp.

template<class T >
Property<T>* RTT::PropertyBag::getPropertyType ( const std::string &  name  )  const [inline]

Get the first Property with name name of a given type T

Parameters:
name The name of the property to search for.
T The data type of the property.
Returns:
The Property<T>* with this name, zero if it does not exist with the given type.

Definition at line 242 of file rtt/PropertyBag.hpp.

template<class T >
Property<T>* RTT::PropertyBag::getPropertyType ( const std::string &  name  )  const [inline]

Get the first Property with name name of a given type T

Parameters:
name The name of the property to search for.
T The data type of the property.
Returns:
The Property<T>* with this name, zero if it does not exist with the given type.

Definition at line 242 of file install/include/rtt/PropertyBag.hpp.

const std::string& RTT::PropertyBag::getType (  )  const [inline]

Definition at line 329 of file rtt/PropertyBag.hpp.

const std::string& RTT::PropertyBag::getType (  )  const [inline]

Definition at line 329 of file install/include/rtt/PropertyBag.hpp.

void RTT::PropertyBag::identify ( base::PropertyBagVisitor pi  )  const

Identify the contents of this bag through introspection.

Deprecated:
DO NOT USE. Will be removed in 2.x release series.
void RTT::PropertyBag::identify ( base::PropertyIntrospection pi  )  const

Identify the contents of this bag through introspection.

Deprecated:
DO NOT USE. Will be removed in 2.x release series.
void RTT::PropertyBag::identify ( base::PropertyBagVisitor pi  )  const

Identify the contents of this bag through introspection.

Deprecated:
DO NOT USE. Will be removed in 2.x release series.

Definition at line 197 of file PropertyBag.cpp.

void RTT::PropertyBag::identify ( base::PropertyIntrospection pi  )  const

Identify the contents of this bag through introspection.

Deprecated:
DO NOT USE. Will be removed in 2.x release series.

Definition at line 187 of file PropertyBag.cpp.

Names RTT::PropertyBag::list (  )  const

List the names of all properties.

Returns:
A container of names.
void RTT::PropertyBag::list ( Names names  )  const

List the names of all properties.

Parameters:
names The container which will be used to store all available property names in.
std::vector< std::string > RTT::PropertyBag::list (  )  const

List the names of all properties.

Returns:
A container of names.

Definition at line 161 of file PropertyBag.cpp.

void RTT::PropertyBag::list ( Names names  )  const

List the names of all properties.

Parameters:
names The container which will be used to store all available property names in.

Definition at line 151 of file PropertyBag.cpp.

PropertyBag& RTT::PropertyBag::operator<< ( base::PropertyBase item  )  [inline]

The 'add' operator. Equivalent to add().

Parameters:
item The Property to add to this bag.

Definition at line 327 of file rtt/PropertyBag.hpp.

PropertyBag& RTT::PropertyBag::operator<< ( base::PropertyBase item  )  [inline]

The 'add' operator. Equivalent to add().

Parameters:
item The Property to add to this bag.

Definition at line 327 of file install/include/rtt/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.

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 251 of file PropertyBag.cpp.

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.

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 234 of file PropertyBag.cpp.

bool RTT::PropertyBag::ownProperty ( base::PropertyBase p  ) 

Set a property to be owned by this bag.

bool RTT::PropertyBag::ownProperty ( base::PropertyBase p  ) 

Set a property to be owned by this bag.

Definition at line 90 of file PropertyBag.cpp.

bool RTT::PropertyBag::ownsProperty ( base::PropertyBase p  )  const

Returns true if this property is owned by this Bag.

bool RTT::PropertyBag::ownsProperty ( base::PropertyBase p  )  const

Returns true if this property is owned by this Bag.

Definition at line 102 of file PropertyBag.cpp.

void RTT::PropertyBag::remove ( base::PropertyBase p  ) 

Remove a property from the container. Analogous to removeProperty.

Parameters:
p Pointer to the property to be removed.
void RTT::PropertyBag::remove ( base::PropertyBase p  ) 

Remove a property from the container. Analogous to removeProperty.

Parameters:
p Pointer to the property to be removed.

Definition at line 85 of file PropertyBag.cpp.

bool RTT::PropertyBag::removeProperty ( base::PropertyBase p  ) 

Remove a property from the container.

Parameters:
p Pointer to the property to be removed.
bool RTT::PropertyBag::removeProperty ( base::PropertyBase p  ) 

Remove a property from the container.

Parameters:
p Pointer to the property to be removed.

Definition at line 122 of file PropertyBag.cpp.

void RTT::PropertyBag::setType ( const std::string &  newtype  )  [inline]

Definition at line 331 of file rtt/PropertyBag.hpp.

void RTT::PropertyBag::setType ( const std::string &  newtype  )  [inline]

Definition at line 331 of file install/include/rtt/PropertyBag.hpp.

size_t RTT::PropertyBag::size (  )  const [inline]

Get the number of Properties in this bag.

Definition at line 264 of file rtt/PropertyBag.hpp.

size_t RTT::PropertyBag::size (  )  const [inline]

Get the number of Properties in this bag.

Definition at line 264 of file install/include/rtt/PropertyBag.hpp.


Member Data Documentation

Definition at line 359 of file install/include/rtt/PropertyBag.hpp.

Definition at line 358 of file install/include/rtt/PropertyBag.hpp.

std::string RTT::PropertyBag::type [protected]

Definition at line 370 of file install/include/rtt/PropertyBag.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Jan 11 09:49:48 2013