39 #ifndef ORO_CORELIB_ATTRIBUTE_HPP 40 #define ORO_CORELIB_ATTRIBUTE_HPP 100 template<
class Owner>
105 o->addAttribute(
this);
125 data( a.data->
clone() )
137 data = a.data->clone();
199 void set( T
const& t )
229 Attribute<T>*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacements,
bool instantiate )
235 replacements[ data.
get() ] = instds;
282 template<
class Owner>
283 Constant(
const std::string& name, T t, Owner owner)
287 owner->addAttribute(
this );
359 Constant<T>*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacements,
bool instantiate )
391 template<
class Owner>
396 owner->addAttribute(
this );
403 Alias*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacements,
bool );
DataSource is a base class representing a generic way to read data of type T.
Constant(const std::string &name, T t, Owner owner)
Create a constant with a fixed value t and an owner.
Constant()
Create a Constant with no name and no value.
virtual result_t get() const =0
Return the data as type T.
Attribute< T > & operator=(const Attribute< T > &a)
Assignment copies both name and deep copy of the data.
Constant(base::AttributeBase *ab)
Create a constant which mirrors an Attribute.
boost::call_traits< value_t >::reference reference_t
Attribute< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacements, bool instantiate)
Returns a copy of this AttributeBase.
virtual void set(param_t t)=0
Set this DataSource with a value.
Constant(const std::string &name, internal::DataSource< T > *d)
Create a constant wich holds a internal::DataSource d.
Constant< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacements, bool instantiate)
Returns a copy of this AttributeBase.
T const & get() const
Get the value of this Attribute.
Attribute(const std::string &name, T t, Owner o)
Create an Attribute with a name, a given value t and an owner.
virtual DataSourceBase::shared_ptr getDataSource() const =0
Return a internal::DataSource which contains the same contents.
internal::AssignableDataSource< T >::shared_ptr getAssignableDataSource() const
Attribute(const std::string &name, T t)
Create an Attribute with a name and a given value t.
base::DataSourceBase::shared_ptr getDataSource() const
Return a internal::DataSource which contains the same contents.
An attribute is a minimalistic, named placeholder for data.
Attribute(const std::string &name, internal::AssignableDataSource< T > *d)
Create an Attribute which uses a internal::DataSource d.
Attribute< T > * clone() const
Returns a clone of this AttributeBase.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
virtual AssignableDataSource< T > * clone() const =0
Return a shallow clone of this DataSource.
base::DataSourceBase::shared_ptr getDataSource() const
Return a internal::DataSource which contains the same contents.
Attribute(const std::string &name)
Create an Attribute with a given name and a default value.
Constant< T > & operator=(base::AttributeBase *ab)
Initialise an Attribute which mirrors an AttributeBase.
Constant< T > * clone() const
Returns a clone of this AttributeBase.
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
A DataSource which holds a constant value and returns it in its get() method.
A DataSource which has set() methods.
Alias(const std::string &name, base::DataSourceBase::shared_ptr d, Owner owner)
Create an alias from a datasource with an owner.
Attribute(base::AttributeBase *ab)
Create an Attribute which mirrors a base::AttributeBase ab.
Attribute(const Attribute< T > &a)
Copy constructor copies both name and deep copy of the data.
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
An Attribute has a name and contains data which can be set and get.
Constant(const std::string &name, T t)
Create a constant with a fixed value t.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
const std::string & getName() const
Get the name of this instance.
internal::DataSource< T >::shared_ptr data
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
As opposed to a Attribute, a Constant can not be assigned to a new value after creation.
This class is the most basic Attribute implementation (only suitable for reading a internal::DataSour...
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
Attribute()
Create an Attribute with no name and no value.
Attribute< T > & operator=(base::AttributeBase *ab)
Initialise an Attribute which mirrors an base::AttributeBase ab.
virtual AssignableDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
Create a deep copy of this internal::DataSource, unless it is already cloned.