38 #ifndef ORO_PROPERTY_HPP 39 #define ORO_PROPERTY_HPP 45 #include <boost/type_traits/remove_const.hpp> 46 #include <boost/call_traits.hpp> 52 #ifdef ORO_PRAGMA_INTERFACE 85 typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type
value_t;
86 typedef typename boost::call_traits<value_t>::param_type
param_t;
87 typedef typename boost::call_traits<value_t>::reference
reference_t;
148 log(
Error) <<
"Cannot initialize Property from " << source->
getName() <<
": ";
150 log() <<
"incompatible type ( destination type: " <<
getType() <<
", source type: " << dsb->getTypeName() <<
")." << endlog();
152 log() <<
"source Property was not ready." << endlog();
167 Property(
const std::string& name,
const std::string& description,
193 if (
this == source )
246 DataSourceType
get()
const 309 return this->
update( *origin );
317 if ( origin != 0 &&
_value ) {
318 return this->
refresh( *origin );
326 if ( origin != 0 &&
_value ) {
327 return this->
copy( *origin );
386 if ( datasource && !prop->ready() ) {
387 log(
Error) <<
"Cannot initialize Property: " 388 <<
"incompatible type ( destination type: " <<
getType() <<
", source type: " << datasource->getTypeName() <<
")." << endlog();
442 std::ostream& operator<<(std::ostream &os, Property<T> &p)
444 #ifdef OS_HAVE_STREAMS 445 os << p.getDataSource();
virtual base::DataSourceBase::shared_ptr getDataSource() const
Get an assignable base::DataSource through which this PropertyBase can be manipulated.
boost::call_traits< value_t >::reference reference_t
Property(const std::string &name)
The constructor which initializes the property's value to the default.
virtual result_t get() const =0
Return the data as type T.
virtual bool refresh(const base::PropertyBase *other)
Refresh the value of this Property with the value of an other Property.
bool ready() const
Inspect if this Property is correctly initialised and ready for usage.
virtual bool copy(const base::PropertyBase *other)
Copy an other Property onto this property.
Property(base::PropertyBase *source)
Create a Property mirroring another PropertyBase.
virtual Property< T > * clone() const
Deliver an identical clone of this PropertyBase.
internal::AssignableDataSource< DataSourceType >::shared_ptr getAssignableDataSource() const
Base class for all properties.
virtual void set(param_t t)=0
Set this DataSource with a value.
virtual void introspect(PropertyBase *p)
Fall-back function of the last resort when the type is not decomposable and not known to the introspe...
virtual void identify(base::PropertyIntrospection *pi)
A call on this method will lead to a call to the PropertyIntrospection interface identifying this Pro...
bool update(const Property< T > &orig)
Update the value, optionally also the description if current description is empty.
const_reference_t rvalue() const
Read-only (const&) access to the value of the Property.
internal::AssignableDataSource< DataSourceType >::shared_ptr _value
Property(const Property< T > &orig)
Copy constructors copies the name, description and value as deep copies.
Property(const std::string &name, const std::string &description, param_t value=value_t())
The constructor which initializes the property's value.
bool copy(const Property< T > &orig)
Copy the value, complete overwrite of this Property with orig.
Property(const std::string &name, const std::string &description, const typename internal::AssignableDataSource< DataSourceType >::shared_ptr &datasource)
The constructor which initializes the property with a DataSource.
virtual Property< T > * create(const base::DataSourceBase::shared_ptr &datasource) const
Create a new instance of the PropertyBase with a custom data source.
reference_t value()
Access to the value of the Property.
static const types::TypeInfo * GetTypeInfo()
Return the Orocos type info.
Property< T > & doc(const std::string &descr)
Documents this property.
boost::call_traits< value_t >::const_reference const_reference_t
std::string _name
A short name for this PropertyBase.
A simple introspection interface to visit PropertyBags.
bool refresh(const Property< T > &orig)
Refresh only the value from a Property.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
A property represents a named value of any type with a description.
Property()
Create an empty Property with no name, no description and no value.
virtual bool setDataSource(const base::DataSourceBase::shared_ptr &dsb)
Assign an external assignable base::DataSource to this property.
A class for representing a user type, and which can build instances of that type. ...
const std::string & getDescription() const
Get a description of the property.
virtual const types::TypeInfo * getTypeInfo() const
Returns the types::TypeInfo object of this Property.
Property< T > & operator=(param_t value)
Set the property's value.
boost::remove_const< typename boost::remove_reference< T >::type >::type value_t
The types of this property type.
void setName(const std::string &name)
Set the name of the property.
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
An interface which all classes which wish to visit a Property should implement.
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded AssignableDataSource, possibly returning a ne...
std::string _description
A lengthy description for this PropertyBase.
virtual std::string getType() const
Returns the type of this PropertyBase.
virtual bool update(const base::PropertyBase *other)
Update the value of this Property with the value of an other Property.
virtual void identify(PropertyIntrospection *pi)=0
A call on this method will lead to a call to the PropertyIntrospection interface identifying this Pro...
const std::string & getName() const
Get the name of the property.
static Property< T > * narrow(base::PropertyBase *prop)
Use this method instead of dynamic_cast<> to cast from base::PropertyBase to Property<T>.
Property< T > & operator=(base::PropertyBase *source)
Mirror another PropertyBase (name, description and value).
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
virtual Property< T > * create() const
Create a new default instance of the PropertyBase.
static std::string GetType()
Return usefull type info in a human readable format.
virtual DataSourceBase::shared_ptr getDataSource() const =0
Get an assignable base::DataSource through which this PropertyBase can be manipulated.
boost::call_traits< value_t >::param_type param_t
void setDescription(const std::string &desc)
Set the description of the property.