Orocos Real-Time Toolkit  2.6.0
Public Member Functions | Protected Attributes
RTT::Attribute< T > Class Template Reference

An Attribute has a name and contains data which can be set and get. More...

#include <rtt/Attribute.hpp>

Inheritance diagram for RTT::Attribute< T >:
RTT::base::AttributeBase

List of all members.

Public Member Functions

 Attribute ()
 Create an Attribute with no name and no value.
 Attribute (const std::string &name)
 Create an Attribute with a given name and a default value.
 Attribute (const std::string &name, T t)
 Create an Attribute with a name and a given value t.
template<class Owner >
 Attribute (const std::string &name, T t, Owner o)
 Create an Attribute with a name, a given value t and an owner.
 Attribute (const std::string &name, internal::AssignableDataSource< T > *d)
 Create an Attribute which uses a internal::DataSource d.
 Attribute (const Attribute< T > &a)
 Copy constructor copies both name and deep copy of the data.
Attribute< T > & operator= (const Attribute< T > &a)
 Assignment copies both name and deep copy of the data.
 Attribute (base::AttributeBase *ab)
 Create an Attribute which mirrors a base::AttributeBase ab.
Attribute< T > & operator= (base::AttributeBase *ab)
 Initialise an Attribute which mirrors an base::AttributeBase ab.
T const & get () const
 Get the value of this Attribute.
void set (T const &t)
 Set the value of this Attribute.
internal::AssignableDataSource
< T >::reference_t 
set ()
 Allow to set the value of this Attribute by reference.
base::DataSourceBase::shared_ptr getDataSource () const
 Return a internal::DataSource which contains the same contents.
internal::AssignableDataSource
< T >::shared_ptr 
getAssignableDataSource () const
Attribute< T > * clone () const
 Returns a clone of this AttributeBase.
Attribute< T > * copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacements, bool instantiate)
 Returns a copy of this AttributeBase.
const std::string & getName () const
 Get the name of this instance.
void setName (std::string const &new_name)
 Get the name of this instance.
bool ready () const
 Returns true if the Attribute was correctly initialised.

Protected Attributes

std::string mname

Detailed Description

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

An Attribute has a name and contains data which can be set and get.

Accessing an attribute (reading/writing) is not thread-safe. It is used to expose a C/C++ variable to the interface of a TaskContext in order to allow plugins or external tools to read and write it.

Parameters:
TThe type of data this attribute holds.

Definition at line 56 of file Attribute.hpp.


Constructor & Destructor Documentation

template<typename T>
RTT::Attribute< T >::Attribute ( const std::string &  name) [inline, explicit]

Create an Attribute with a given name and a default value.

Parameters:
nameThe name of this instance.

Definition at line 74 of file Attribute.hpp.

template<typename T>
RTT::Attribute< T >::Attribute ( const std::string &  name,
t 
) [inline]

Create an Attribute with a name and a given value t.

Parameters:
nameThe name of this instance.
tThe value for initialisation.

Definition at line 85 of file Attribute.hpp.

template<typename T>
template<class Owner >
RTT::Attribute< T >::Attribute ( const std::string &  name,
t,
Owner  o 
) [inline]

Create an Attribute with a name, a given value t and an owner.

The owner is used to register this attribute to and is supposed to be a pointer (or shared pointer).

Parameters:
nameThe name of this instance.
tThe value for initialisation.
oThe owner, which has a function 'addAttribute(AttributeBase*)'.

Definition at line 101 of file Attribute.hpp.

template<typename T>
RTT::Attribute< T >::Attribute ( const std::string &  name,
internal::AssignableDataSource< T > *  d 
) [inline]

Create an Attribute which uses a internal::DataSource d.

Parameters:
nameThe name
dThe data source to read from and write to.

Definition at line 114 of file Attribute.hpp.

template<typename T>
RTT::Attribute< T >::Attribute ( base::AttributeBase ab) [inline]

Create an Attribute which mirrors a base::AttributeBase ab.

If successful, this attribute will always have the same value as ab and vice versa.

Parameters:
abThe Attribute to mirror. If null, this will clear this attribute and clear its name.
See also:
ready() to check if ab was accepted.

Definition at line 150 of file Attribute.hpp.


Member Function Documentation

template<typename T>
Attribute<T>* RTT::Attribute< T >::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  replacements,
bool  instantiate 
) [inline, virtual]

Returns a copy of this AttributeBase.

Uses the given replacements to copy held DataSources.

Parameters:
instantiateSet to true to get a copy which will return itself on any future copy request.

Implements RTT::base::AttributeBase.

Definition at line 229 of file Attribute.hpp.

const std::string & RTT::AttributeBase::getName ( ) const [inherited]
template<typename T>
Attribute<T>& RTT::Attribute< T >::operator= ( base::AttributeBase ab) [inline]

Initialise an Attribute which mirrors an base::AttributeBase ab.

If successful, this attribute will always have the same value as ab and vice versa.

Parameters:
abThe attribute to mirror. If null, this will clear this attribute and clear its name.
See also:
ready() to check if ab was accepted.

Definition at line 164 of file Attribute.hpp.

References RTT::base::AttributeBase::getDataSource(), and RTT::base::AttributeBase::getName().

template<typename T>
void RTT::Attribute< T >::set ( T const &  t) [inline]

Set the value of this Attribute.

In case the attribute is owned by a remote component, the value will be transfered.

Definition at line 199 of file Attribute.hpp.

template<typename T>
internal::AssignableDataSource<T>::reference_t RTT::Attribute< T >::set ( ) [inline]

Allow to set the value of this Attribute by reference.

Don't use this function to set attributes of remote components, since set() will return in that case a copy of the data and the remote side will not be updated.

Definition at line 210 of file Attribute.hpp.

void RTT::AttributeBase::setName ( std::string const &  new_name) [inherited]

Get the name of this instance.

Returns:
the name

Definition at line 64 of file Attribute.cpp.

Referenced by RTT::ConfigurationInterface::addAttribute(), and RTT::ConfigurationInterface::addConstant().


The documentation for this class was generated from the following file: