RTT::Property< T > Class Template Reference
[Property InterfaceTask Context Interface]

A property represents a named value of any type with a description. More...

#include <rtt/Property.hpp>

Inheritance diagram for RTT::Property< T >:
RTT::PropertyBase

List of all members.

Public Types

typedef boost::remove_const
< typename
boost::remove_reference< T >
::type >::type 
value_t
 The types of this property type.
typedef boost::call_traits
< value_t >::param_type 
param_t
typedef boost::call_traits
< value_t >::reference 
reference_t
typedef boost::call_traits
< value_t >::const_reference 
const_reference_t
typedef value_t DataSourceType

Public Member Functions

 Property ()
 Create an empty Property with no name, no description and no value.
 Property (const std::string &name, const std::string &description, param_t value=value_t())
 The constructor which initializes the property's value.
 Property (const Property< T > &orig)
 Copy constructors copies the name, description and value as deep copies.
 Property (PropertyBase *source)
 Create a Property mirroring another PropertyBase.
 Property (const std::string &name, const std::string &description, typename AssignableDataSource< DataSourceType >::shared_ptr datasource)
 The constructor which initializes the property with a DataSource.
Property< T > & operator= (param_t value)
 Set the property's value.
Property< T > & operator= (PropertyBase *source)
 Construct a Property which mirrors a PropertyBase.
Property< T > & operator<<= (Property< T > &p)
 Update the value of this property with another property.
 operator value_t () const
 Get a copy of the value of the property.
DataSourceType get () const
 Get a copy of the value of the property.
reference_t set ()
 Access to the value of the Property.
void set (param_t v)
 Set the value of the Property.
reference_t value ()
 Access to the value of the Property.
const_reference_t rvalue () const
 Read-only (const&) access to the value of the Property.
virtual void identify (PropertyIntrospection *pi)
 A call on this method will lead to a call to the PropertyIntrospection interface identifying this Property's proper type.
virtual void identify (PropertyBagVisitor *pi)
 A call on this method will lead to a call to the PropertyBagIntrospection interface identifying this Property's proper type.
virtual bool update (const PropertyBase *other)
 Update the value of this Property with the value of an other Property.
virtual CommandInterfaceupdateCommand (const PropertyBase *other)
 Generate a CommandInterface object which will update this Property with the value of another Property when execute()'ed.
virtual bool refresh (const PropertyBase *other)
 Refresh the value of this Property with the value of an other Property.
virtual CommandInterfacerefreshCommand (const PropertyBase *other)
 Generate a CommandInterface object which will refresh this Property with the value of another Property when execute()'ed.
virtual bool copy (const PropertyBase *other)
 Copy an other Property onto this property.
virtual CommandInterfacecopyCommand (const PropertyBase *other)
 Generate a CommandInterface object which will copy this Property with the value of another Property when execute()'ed.
bool copy (const Property< T > &orig)
 Copy the value, complete overwrite of this Property with orig.
bool update (const Property< T > &orig)
 Update the value, optionally also the description if current description is empty.
bool refresh (const Property< T > &orig)
 Refresh only the value from a Property.
virtual Property< T > * clone () const
 Deliver an identical clone of this PropertyBase.
virtual Property< T > * create () const
 Create a new default instance of the PropertyBase.
virtual DataSourceBase::shared_ptr getDataSource () const
 Get a DataSource through which this PropertyBase can be manipulated.
AssignableDataSource
< DataSourceType >::shared_ptr 
getAssignableDataSource () const
virtual std::string getType () const
 Returns the type of this PropertyBase.
virtual const TypeInfogetTypeInfo () const
 Returns the TypeInfo object of this Property.
template<>
RTT_API bool update (const Property< PropertyBag > &orig)
template<>
RTT_API bool refresh (const Property< PropertyBag > &orig)
template<>
RTT_API bool copy (const Property< PropertyBag > &orig)
template<>
RTT_API void identify (PropertyBagVisitor *pbi)
 A call on this method will lead to a call to the PropertyBagIntrospection interface identifying this Property's proper type.
const std::string & getName () const
 Get the name of the property.
void setName (const std::string &name)
 Set the name of the property.
const std::string & getDescription () const
 Get a description of the property.
void setDescription (const std::string &desc)
 Set the description of the property.
bool ready () const
 Inspect if this Property is correctly initialised and ready for usage.

Static Public Member Functions

static Property< T > * narrow (PropertyBase *prop)
 Use this method instead of dynamic_cast<> to cast from PropertyBase to Property<T>.

Protected Attributes

AssignableDataSource
< DataSourceType >::shared_ptr 
_value
std::string _name
 A short name for this PropertyBase.
std::string _description
 A lengthy description for this PropertyBase.

Detailed Description

template<typename T>
class RTT::Property< T >

A property represents a named value of any type with a description.

A property is a tuple of a name, a description and a variable of any type. It's purpose is to provide an easy to manipulate parameter of an object by external entities. They can be grouped in PropertyBag objects and a Property can contain a PropertyBag itself.

If you do not provide a name nor description when constructing the Property object, it will be uninitialised and ready() will return false. Such an object may not be used (set(), get(),...) until it has been initialised from another Property. Otherwise, an exception (or assert) will be thrown.

Parameters:
T The type of the data contained within the Property.

Definition at line 78 of file Property.hpp.


Member Typedef Documentation

template<typename T>
typedef boost::remove_const<typename boost::remove_reference<T>::type>::type RTT::Property< T >::value_t

The types of this property type.

value_t is always the 'bare' value type of T. From this type, we derive the other (param, ref, ...) types.

Definition at line 87 of file Property.hpp.


Constructor & Destructor Documentation

template<typename T>
RTT::Property< T >::Property (  )  [inline]

Create an empty Property with no name, no description and no value.

Postcondition:
ready() will return false. Initialise this Property with another Property object.

Definition at line 97 of file Property.hpp.

template<typename T>
RTT::Property< T >::Property ( const std::string &  name,
const std::string &  description,
param_t  value = value_t() 
) [inline]

The constructor which initializes the property's value.

Parameters:
name The name which will be used to refer to the property.
description The description of the property.
value The initial value of the property (optional).
Postcondition:
ready() will always be true.

Definition at line 108 of file Property.hpp.

template<typename T>
RTT::Property< T >::Property ( const Property< T > &  orig  )  [inline]

Copy constructors copies the name, description and value as deep copies.

Postcondition:
ready() will be true if orig.ready() is true.

Definition at line 118 of file Property.hpp.

template<typename T>
RTT::Property< T >::Property ( PropertyBase source  )  [inline]

Create a Property mirroring another PropertyBase.

It copies the name and description, and shallow copies the value.

See also:
ready() to inspect if the creation succeeded.

Definition at line 129 of file Property.hpp.

template<typename T>
RTT::Property< T >::Property ( const std::string &  name,
const std::string &  description,
typename AssignableDataSource< DataSourceType >::shared_ptr  datasource 
) [inline]

The constructor which initializes the property with a DataSource.

Parameters:
name The name which will be used to refer to the property.
description The description of the property.
datasource A new data source to be acquired by this property for storing its data.
Postcondition:
ready() will be true if datasource is a valid pointer.

Definition at line 144 of file Property.hpp.


Member Function Documentation

template<typename T>
virtual Property<T>* RTT::Property< T >::clone (  )  const [inline, virtual]

Deliver an identical clone of this PropertyBase.

The original may be deleted and the clone can be transparantly used in its place or vice versa.

Implements RTT::PropertyBase.

Definition at line 360 of file Property.hpp.

Referenced by RTT::Property< T >::narrow().

template<typename T>
virtual bool RTT::Property< T >::copy ( const PropertyBase other  )  [inline, virtual]

Copy an other Property onto this property.

Update does a full update of the name, description and value, adding extra information if necessary, or in case of a Property<PropertyBag> adding all Properties.

Returns:
false if the Properties are of different type.

Implements RTT::PropertyBase.

Definition at line 304 of file Property.hpp.

Referenced by RTT::Property< bool >::copy().

template<typename T>
virtual CommandInterface* RTT::Property< T >::copyCommand ( const PropertyBase other  )  [inline, virtual]

Generate a CommandInterface object which will copy this Property with the value of another Property when execute()'ed.

Returns:
zero if the Property types do not match

Implements RTT::PropertyBase.

Definition at line 313 of file Property.hpp.

template<typename T>
virtual Property<T>* RTT::Property< T >::create (  )  const [inline, virtual]

Create a new default instance of the PropertyBase.

This is a factory method to 'make something of the same type'. The new PropertyBase has the same name and description as this.

Implements RTT::PropertyBase.

Definition at line 365 of file Property.hpp.

template<typename T>
DataSourceType RTT::Property< T >::get ( void   )  const [inline]
const std::string& RTT::PropertyBase::getDescription ( void   )  const [inline, inherited]
const std::string& RTT::PropertyBase::getName ( void   )  const [inline, inherited]
template<typename T>
virtual std::string RTT::Property< T >::getType (  )  const [inline, virtual]

Returns the type of this PropertyBase.

Uses the naming scheme of DataSourceTypeInfo.

Implements RTT::PropertyBase.

Definition at line 378 of file Property.hpp.

Referenced by RTT::decomposeProperty().

template<class T >
Property< T > * RTT::Property< T >::narrow ( PropertyBase prop  )  [inline, static]

Use this method instead of dynamic_cast<> to cast from PropertyBase to Property<T>.

You need to delete the returned property if it is no longer needed.

Parameters:
T The Desired property type, for example 'double'.
prop The property to narrow to Property<T>.
Returns:
Null if prop is not convertible to type Property<T>, a new Property<T> instance otherwise.

Definition at line 412 of file Property.hpp.

References RTT::Property< T >::clone(), and RTT::PropertyBase::getDataSource().

Referenced by RTT::Property< bool >::operator=().

template<typename T>
RTT::Property< T >::operator value_t (  )  const [inline]

Get a copy of the value of the property.

Returns:
A copy of the value of the property.

Definition at line 200 of file Property.hpp.

template<typename T>
Property<T>& RTT::Property< T >::operator= ( PropertyBase source  )  [inline]

Construct a Property which mirrors a PropertyBase.

Parameters:
source A pointer to the property to mirror.

Definition at line 164 of file Property.hpp.

template<typename T>
Property<T>& RTT::Property< T >::operator= ( param_t  value  )  [inline]

Set the property's value.

Parameters:
value The value to be set.
Returns:
A reference to newly set property value.

Definition at line 154 of file Property.hpp.

bool RTT::PropertyBase::ready (  )  const [inline, inherited]

Inspect if this Property is correctly initialised and ready for usage.

A Property may only be used when ready() returns true, otherwise, an exception is thrown.

Definition at line 113 of file PropertyBase.hpp.

Referenced by RTT::Property< bool >::copy(), RTT::PropertyBag::findValue(), RTT::Property< bool >::refresh(), and RTT::Property< bool >::update().

template<typename T>
bool RTT::Property< T >::refresh ( const Property< T > &  orig  )  [inline]

Refresh only the value from a Property.

This is a real-time operation.

Definition at line 352 of file Property.hpp.

template<typename T>
virtual bool RTT::Property< T >::refresh ( const PropertyBase other  )  [inline, virtual]

Refresh the value of this Property with the value of an other Property.

Refresh does only the minimal update of the value, not adding extra information, or in case of a Property<PropertyBag> not adding extra Properties.

Returns:
false if the Properties are of different type.

Implements RTT::PropertyBase.

Definition at line 286 of file Property.hpp.

Referenced by RTT::Property< bool >::refresh().

template<typename T>
virtual CommandInterface* RTT::Property< T >::refreshCommand ( const PropertyBase other  )  [inline, virtual]

Generate a CommandInterface object which will refresh this Property with the value of another Property when execute()'ed.

The resulting Command is real-time.

Returns:
zero if the Property types do not match

Implements RTT::PropertyBase.

Definition at line 295 of file Property.hpp.

template<typename T>
reference_t RTT::Property< T >::set (  )  [inline]

Access to the value of the Property.

Identical to value().

Warning:
This function is not suitable for remote (distributed) access of properties, use operator=() or set( param_t v ) to assign a value.

Definition at line 220 of file Property.hpp.

void RTT::PropertyBase::setDescription ( const std::string &  desc  )  [inherited]

Set the description of the property.

Parameters:
desc The description of the property.

Referenced by RTT::Property< bool >::operator=().

void RTT::PropertyBase::setName ( const std::string &  name  )  [inherited]

Set the name of the property.

Parameters:
name The name of the property.

Referenced by RTT::Property< bool >::operator=().

template<typename T>
virtual bool RTT::Property< T >::update ( const PropertyBase other  )  [inline, virtual]

Update the value of this Property with the value of an other Property.

Update does a full update of the value, adding extra information if necessary, or in case of a Property<PropertyBag> adding missing Properties.

Returns:
false if the Properties are of different type.

Implements RTT::PropertyBase.

Definition at line 268 of file Property.hpp.

Referenced by RTT::Property< bool >::operator<<=(), and RTT::Property< bool >::update().

template<typename T>
virtual CommandInterface* RTT::Property< T >::updateCommand ( const PropertyBase other  )  [inline, virtual]

Generate a CommandInterface object which will update this Property with the value of another Property when execute()'ed.

Returns:
zero if the Property types do not match
Todo:
: check if this method is necessary/used.

Implements RTT::PropertyBase.

Definition at line 277 of file Property.hpp.

template<typename T>
reference_t RTT::Property< T >::value ( void   )  [inline]

Access to the value of the Property.

Identical to set().

Warning:
This function is not suitable for remote (distributed) access of properties, use operator=() or set( param_t v ) to assign a value.

Definition at line 240 of file Property.hpp.

Referenced by RTT::decomposeProperty(), RTT::PropertyBag::findValue(), RTT::PropertyBagIntrospector::introspect(), and RTT::TableMarshaller< o_stream >::serialize().


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:44 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3