Orocos Real-Time Toolkit  2.6.0
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
RTT::ConfigurationInterface Class Reference

A class for keeping track of Attribute, Constant and Property objects of a TaskContext. More...

#include <rtt/ConfigurationInterface.hpp>

Inheritance diagram for RTT::ConfigurationInterface:
RTT::Service RTT::types::GlobalsRepository RTT::internal::GlobalService RTT::marsh::MarshallingService RTT::scripting::ProgramService RTT::scripting::ScriptingService RTT::scripting::StateMachineService

List of all members.

Public Types

typedef std::vector< std::string > AttributeNames
 A vector containing the names of all attribute objects in this repository.
typedef std::vector
< base::AttributeBase * > 
AttributeObjects
 A vector containing pointers to all attribute objects stored in this repository.

Public Member Functions

 ConfigurationInterface ()
 Create an empty ConfigurationInterface.
void clear ()
 Erases the whole repository.
bool hasAttribute (const std::string &name) const
 Check if an attribute is present in this interface.
template<class T >
bool addAttribute (const std::string &name, T &attr)
 Adds a variable of any type as read/write attribute to the configuration interface.
template<class T >
Attribute< T > & addAttribute (const std::string &name, Attribute< T > &attr)
 Adds an existing attribute object to the configuration interface.
template<class T >
bool addConstant (const std::string &name, const T &cnst)
 Adds a variable of any type as read-only attribute to the configuration interface.
template<class T >
Constant< T > & addConstant (const std::string &name, Constant< T > &cnst)
 Adds an existing constant object to the configuration interface.
template<class T >
Property< T > & addProperty (const std::string &name, T &prop)
 Adds a variable of any type as a property to the configuration interface.
template<class T >
Property< T > & addProperty (const std::string &name, Property< T > &prop)
 Adds an existing property object to the configuration interface.
bool addAttribute (base::AttributeBase &a)
 Add an base::AttributeBase which remains owned by the user.
base::AttributeBasegetAttribute (const std::string &name) const
void removeAttribute (const std::string &name)
 Remove an attribute from the repository.
bool addConstant (base::AttributeBase &c)
 Add a Constant with a given value.
base::AttributeBasegetConstant (const std::string &name) const
bool hasProperty (const std::string &name) const
 Check if a property is present.
bool addProperty (base::PropertyBase &pb)
 Add an base::PropertyBase as a property.
bool removeProperty (base::PropertyBase &p)
 Remove a previously added Property and associated attribute.
base::PropertyBasegetProperty (const std::string &name) const
 Get a Property with name name.
bool setValue (base::AttributeBase *ab)
 Transfer the ownership of an attribute to the repository.
base::AttributeBasegetValue (const std::string &name) const
bool removeValue (const std::string &name)
 Delete a value added with setValue from the repository.
ConfigurationInterfacecopy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &repl, bool instantiate) const
 Return a new copy of this repository with the copy operation semantics.
void loadValues (AttributeObjects const &new_values)
 Adds these attributes to this repository.
AttributeObjects const & getValues () const
 Returns all attributes in this repository.
AttributeNames getAttributeNames () const
 Return the names of all attributes in this repository.
PropertyBagproperties ()
 Return a bag of all properties.

Protected Types

typedef std::vector
< base::AttributeBase * > 
map_t

Protected Member Functions

bool chkPtr (const std::string &where, const std::string &name, const void *ptr)

Protected Attributes

map_t values
PropertyBag bag

Detailed Description

A class for keeping track of Attribute, Constant and Property objects of a TaskContext.

It allows plugins and remote components to browse the attributes and properties of a TaskContext.

Definition at line 60 of file ConfigurationInterface.hpp.


Member Function Documentation

template<class T >
bool RTT::ConfigurationInterface::addAttribute ( const std::string &  name,
T &  attr 
) [inline]

Adds a variable of any type as read/write attribute to the configuration interface.

An Alias is created which causes contents of the attr variable always to be in sync with the contents of the attribute object in the interface.

Parameters:
nameThe name of this attribute
attrThe variable that will be aliased.

Definition at line 101 of file ConfigurationInterface.hpp.

template<class T >
Attribute<T>& RTT::ConfigurationInterface::addAttribute ( const std::string &  name,
Attribute< T > &  attr 
) [inline]

Adds an existing attribute object to the configuration interface.

Parameters:
nameThe name of this attribute. attr will be initialized with this name.
attrThe attribute to add
Returns:
the Attribute object by reference, which you can further query or use.
Postcondition:
attr.ready() == true

Definition at line 115 of file ConfigurationInterface.hpp.

References RTT::base::AttributeBase::ready(), and RTT::base::AttributeBase::setName().

Add an base::AttributeBase which remains owned by the user.

This is a low-level function that can be used if you already created an Attribute object that does not belong yet to a service.

Parameters:
aremains owned by the user, and becomes served by the repository.

Definition at line 204 of file ConfigurationInterface.hpp.

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

template<class T >
bool RTT::ConfigurationInterface::addConstant ( const std::string &  name,
const T &  cnst 
) [inline]

Adds a variable of any type as read-only attribute to the configuration interface.

An Alias is created which causes contents of the attribute always to be in sync with the contents of cnst, but it can only be read through the interface.

Parameters:
nameThe name of this attribute
cnstThe variable that will be aliased.

Definition at line 135 of file ConfigurationInterface.hpp.

template<class T >
Constant<T>& RTT::ConfigurationInterface::addConstant ( const std::string &  name,
Constant< T > &  cnst 
) [inline]

Adds an existing constant object to the configuration interface.

Parameters:
nameThe name of this constant. cnst will be initialized with this name.
cnstThe constant to add. If cnst has not been initialized, it will be initialized to T(). You can change it later-on using the Constant's API.
Returns:
the Constant object by reference, which you can further query or use.
Postcondition:
cnst.ready() == true

Definition at line 150 of file ConfigurationInterface.hpp.

References RTT::base::AttributeBase::ready(), and RTT::base::AttributeBase::setName().

Add a Constant with a given value.

See also:
getConstant

Definition at line 232 of file ConfigurationInterface.hpp.

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

template<class T >
Property<T>& RTT::ConfigurationInterface::addProperty ( const std::string &  name,
T &  prop 
) [inline]

Adds a variable of any type as a property to the configuration interface.

A Property is created which causes contents of the property always to be in sync with the contents of prop.

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

Definition at line 171 of file ConfigurationInterface.hpp.

Referenced by RTT::scripting::ScriptingService::ScriptingService().

template<class T >
Property<T>& RTT::ConfigurationInterface::addProperty ( const std::string &  name,
Property< T > &  prop 
) [inline]

Adds an existing property object to the configuration interface.

Parameters:
nameThe name of this property. prop will be initialized with this name.
propThe property to add
Returns:
the Property object by reference, which you can further query or document.
Postcondition:
prop.ready() == true

Definition at line 184 of file ConfigurationInterface.hpp.

References RTT::base::PropertyBase::ready(), and RTT::base::PropertyBase::setName().

Add an base::PropertyBase as a property.

Returns:
false if a property with the same name already exists.
See also:
removeProperty

Definition at line 90 of file ConfigurationInterface.cpp.

References RTT::base::PropertyBase::getName().

ConfigurationInterface * RTT::ConfigurationInterface::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  repl,
bool  instantiate 
) const

Return a new copy of this repository with the copy operation semantics.

Parameters:
instantiateset to true if you want a copy which will upon any future copy return the same DataSources, thus 'fixating' or 'instantiating' the DataSources.
See also:
base::ActionInterface
Note:
this does not copy the properties() within this repository.

Definition at line 60 of file ConfigurationInterface.cpp.

References setValue().

Referenced by RTT::scripting::ScriptingService::loadFunctions(), RTT::scripting::ScriptingService::loadPrograms(), RTT::scripting::ScriptingService::loadStateMachines(), and RTT::scripting::ScriptingService::runScript().

base::PropertyBase* RTT::ConfigurationInterface::getProperty ( const std::string &  name) const [inline]

Get a Property with name name.

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

Definition at line 275 of file ConfigurationInterface.hpp.

Remove a previously added Property and associated attribute.

Returns:
false if no such property exists.

Definition at line 129 of file ConfigurationInterface.cpp.

References RTT::base::PropertyBase::getName().

Transfer the ownership of an attribute to the repository.

Parameters:
abThe attribute which becomes owned by this repository.
Returns:
false if an Attribute with the same name already present.

Definition at line 78 of file ConfigurationInterface.cpp.

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

Referenced by copy().


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