A DataObjectInterface extends the AssignableDataSource with implementations of multi-threaded read/write solutions. More...
#include <rtt/DataObjectInterfaces.hpp>
Public Types | |
typedef boost::intrusive_ptr < DataObjectInterface< T > > | shared_ptr |
If you plan to use a reference counted DataObject, use this type to store it and apply this->deref() to enable reference counting. | |
typedef T | DataType |
The type of the data. | |
typedef DataSource< T >::value_t | value_t |
The bare type of T is extracted into value_t. | |
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 boost::remove_const < typename boost::call_traits < value_t >::param_type > ::type | copy_t |
typedef boost::intrusive_ptr < const AssignableDataSource < T > > | const_ptr |
Use this type to store a const pointer to a DataSourceBase. | |
typedef T | result_t |
Public Member Functions | |
DataObjectInterface () | |
Create a DataObject which is initially not reference counted. | |
virtual | ~DataObjectInterface () |
Destructor. | |
virtual void | Get (DataType &pull) const =0 |
Get a copy of the Data of this data object. | |
virtual DataType | Get () const =0 |
Get a copy of the data of this data object. | |
virtual void | Set (const DataType &push)=0 |
Set the data to a certain value. | |
virtual const std::string & | getName () const =0 |
Return the name of this DataObject. | |
DataSource< T >::result_t | value () const |
Normally, value() does not trigger a get(), but for DataObjects, this is actually the sanest thing to do. | |
virtual DataSource< DataType > ::result_t | get () const |
Return the data as type T. | |
virtual void | set (typename AssignableDataSource< DataType >::param_t t) |
virtual AssignableDataSource < DataType >::reference_t | set () |
Get a reference (or null) to the value of this DataSource. | |
virtual AssignableDataSource < DataType > ::const_reference_t | rvalue () const |
Get a const reference (or null) to the value of this DataSource. | |
virtual void | set (param_t t)=0 |
Set this DataSource with a value. | |
virtual bool | update (DataSourceBase *other) |
Update the value of this DataSource with the value of an other DataSource. | |
virtual CommandInterface * | updateCommand (DataSourceBase *other) |
Generate a CommandInterface object which will update this DataSource with the value of another DataSource when execute()'ed. | |
virtual AssignableDataSource< T > * | clone () const =0 |
Return a shallow clone of this DataSource. | |
virtual AssignableDataSource< T > * | copy (std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const =0 |
Create a deep copy of this DataSource, unless it is already cloned. | |
virtual bool | updateBlob (int protocol, const void *data) |
Updates the value of this DataSource with the value of a transportable data object. | |
virtual void * | server (int protocol, void *data) |
Create an object server which 'mirrors' this DataSource. | |
virtual bool | evaluate () const |
Force an evaluation of the DataSourceBase. | |
template<> | |
RTT_API bool | evaluate () const |
Force an evaluation of the DataSourceBase. | |
virtual std::string | getType () const |
Return useful type info in a human readable format. | |
virtual const TypeInfo * | getTypeInfo () const |
Return the Orocos type info object. | |
virtual std::string | getTypeName () const |
Return the Orocos type name, without const, pointer or reference qualifiers. | |
void | ref () const |
Increase the reference count by one. | |
void | deref () const |
Decrease the reference count by one and delete this on zero. | |
virtual void | reset () |
Reset the data to initial values. | |
virtual void | updated () |
In case the DataSource returns a 'reference' type, call this method to notify it that the data was updated in the course of an invocation of get(). | |
virtual bool | updatePart (DataSourceBase *part, DataSourceBase *other) |
Update part of the value of this DataSource with the value of an other DataSource. | |
virtual CommandInterface * | updatePartCommand (DataSourceBase *part, DataSourceBase *other) |
Generate a CommandInterface object which will partially update this DataSource with the value of another DataSource when execute()'ed. | |
std::ostream & | write (std::ostream &os) |
Stream the contents of this object. | |
std::string | toString () |
Get the contents of this object as a string. | |
bool | decomposeType (PropertyBag &targetbag) |
Decompose the contents of this object into properties. | |
bool | composeType (DataSourceBase::shared_ptr source) |
Compose the contents of this object from another datasource. | |
virtual void * | createBlob (int protocol) |
Creates a transportable data object with the current value of this DataSource. | |
virtual void * | getBlob (int protocol) |
Creates a transportable data object with the current value of this DataSource. | |
virtual int | serverProtocol () const |
Inspect if this DataSource is a proxy for a remote server object. | |
virtual void * | method (int protocol, MethodC *orig, void *arg) |
Create an object server which 'mirrors' this DataSource. | |
Static Public Member Functions | |
static AssignableDataSource< T > * | narrow (DataSourceBase *db) |
This method narrows a DataSourceBase to a typeded AssignableDataSource, possibly returning a new object. | |
static std::string | GetType () |
Return usefull type info in a human readable format. | |
static const TypeInfo * | GetTypeInfo () |
Return the Orocos type info. | |
static std::string | GetTypeName () |
Return the Orocos type name, without const, pointer or reference qualifiers. | |
Protected Attributes | |
OS::AtomicInt | refcount |
We keep the refcount ourselves. |
A DataObjectInterface extends the AssignableDataSource with implementations of multi-threaded read/write solutions.
It is initially not reference counted, such that DataObjects may be created on the stack. Store a DataObject in a shared_ptr and use this->deref() to get a reference counted version. This dual policy was introduced to be consistent with the other buffer implementations.
T | The DataType which can be Get() or Set() with this DataObject. |
Definition at line 64 of file DataObjectInterfaces.hpp.
virtual AssignableDataSource<T>* RTT::AssignableDataSource< T >::clone | ( | ) | const [pure virtual, inherited] |
Return a shallow clone of this DataSource.
This method returns a duplicate of this instance which re-uses the DataSources this DataSource holds reference to. The clone() function is thus a non-deep copy.
Implements RTT::DataSource< T >.
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::Corba::CORBAAssignableExpression< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, RTT::DataObject< T >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >, RTT::detail::AssignableDataSourceAdaptor< To const &, To >, RTT::ValueDataSource< T >, RTT::ReferenceDataSource< T >, RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >, RTT::ValueDataSource< arg3_type >, RTT::ValueDataSource< StateMachineWPtr >, RTT::ValueDataSource< R >, RTT::ValueDataSource< A >, RTT::ValueDataSource< arg4_type >, RTT::ValueDataSource< ProgramInterfaceWPtr >, RTT::ValueDataSource< arg2_type >, RTT::ValueDataSource< arg1_type >, and RTT::ValueDataSource< boost::function_traits< DataType >::result_type >.
Referenced by RTT::detail::AssignableDataSourceAdaptor< To const &, To >::clone(), and RTT::detail::AssignableDataSourceAdaptor< From, const From & >::clone().
bool RTT::DataSourceBase::composeType | ( | DataSourceBase::shared_ptr | source | ) | [inherited] |
Compose the contents of this object from another datasource.
virtual AssignableDataSource<T>* RTT::AssignableDataSource< T >::copy | ( | std::map< const DataSourceBase *, DataSourceBase * > & | alreadyCloned | ) | const [pure virtual, inherited] |
Create a deep copy of this DataSource, unless it is already cloned.
Places the association (parent, clone) in alreadyCloned. If the DataSource is non-copyable (for example it represents the Property of a Task ), this may be returned.
Implements RTT::DataSource< T >.
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::Corba::CORBAAssignableExpression< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, RTT::DataObject< T >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >, RTT::detail::AssignableDataSourceAdaptor< To const &, To >, RTT::ValueDataSource< T >, RTT::ReferenceDataSource< T >, RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >, RTT::ValueDataSource< arg3_type >, RTT::ValueDataSource< StateMachineWPtr >, RTT::ValueDataSource< R >, RTT::ValueDataSource< A >, RTT::ValueDataSource< arg4_type >, RTT::ValueDataSource< ProgramInterfaceWPtr >, RTT::ValueDataSource< arg2_type >, RTT::ValueDataSource< arg1_type >, and RTT::ValueDataSource< boost::function_traits< DataType >::result_type >.
Referenced by RTT::detail::AssignableDataSourceAdaptor< To const &, To >::copy(), and RTT::detail::AssignableDataSourceAdaptor< From, const From & >::copy().
virtual void* RTT::DataSourceBase::createBlob | ( | int | protocol | ) | [virtual, inherited] |
Creates a transportable data object with the current value of this DataSource.
This does not trigger the evaluation() of this data source.
Reimplemented in RTT::Corba::ExpressionProxy.
Referenced by RTT::Corba::CorbaDataObjectProxy< T >::Set().
bool RTT::DataSourceBase::decomposeType | ( | PropertyBag & | targetbag | ) | [inherited] |
Decompose the contents of this object into properties.
RTT_API bool RTT::DataSource< bool >::evaluate | ( | ) | const [inline, virtual, inherited] |
Force an evaluation of the DataSourceBase.
Implements RTT::DataSourceBase.
bool RTT::DataSource< T >::evaluate | ( | ) | const [inline, virtual, inherited] |
Force an evaluation of the DataSourceBase.
Implements RTT::DataSourceBase.
Reimplemented in RTT::detail::DataSourceAdaptor< From, To >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom >, RTT::detail::DataSourceAdaptor< const TFrom &, const TFrom >, RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >, RTT::detail::DataSourceAdaptor< TFrom, const TFrom & >, RTT::detail::DataSourceAdaptor< const TFrom, const TFrom & >, RTT::detail::AssignableDataSourceAdaptor< From, To >, RTT::detail::AssignableDataSourceAdaptor< From, const From & >, and RTT::detail::AssignableDataSourceAdaptor< To const &, To >.
Definition at line 52 of file DataSource.inl.
Referenced by RTT::detail::AssignableDataSourceAdaptor< To const &, To >::evaluate(), RTT::detail::AssignableDataSourceAdaptor< From, const From & >::evaluate(), RTT::detail::AssignableDataSourceAdaptor< From, To >::evaluate(), RTT::detail::DataSourceAdaptor< const TFrom, const TFrom & >::evaluate(), RTT::detail::DataSourceAdaptor< TFrom, const TFrom & >::evaluate(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >::evaluate(), RTT::detail::DataSourceAdaptor< const TFrom &, const TFrom >::evaluate(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom >::evaluate(), RTT::detail::DataSourceAdaptor< From, To >::evaluate(), and RTT::detail::AssignableDataSourceAdaptor< From, const From & >::get().
virtual DataType RTT::DataObjectInterface< T >::Get | ( | ) | const [pure virtual] |
Get a copy of the data of this data object.
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, and RTT::DataObject< T >.
Referenced by RTT::DataObjectInterface< T >::get(), and RTT::DataObjectInterface< T >::value().
virtual void RTT::DataObjectInterface< T >::Get | ( | DataType & | pull | ) | const [pure virtual] |
Get a copy of the Data of this data object.
pull | A copy of the data. |
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, and RTT::DataObject< T >.
virtual void* RTT::DataSourceBase::getBlob | ( | int | protocol | ) | [virtual, inherited] |
Creates a transportable data object with the current value of this DataSource.
This does trigger the evaluation() of this data source. Equivalent to this->evaluate(); this->createBlob();
Reimplemented in RTT::Corba::ExpressionProxy.
virtual const std::string& RTT::DataObjectInterface< T >::getName | ( | ) | const [pure virtual] |
Return the name of this DataObject.
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, and RTT::DataObject< T >.
virtual void* RTT::DataSourceBase::method | ( | int | protocol, | |
MethodC * | orig, | |||
void * | arg | |||
) | [virtual, inherited] |
Create an object server which 'mirrors' this DataSource.
Reimplemented in RTT::Corba::ExpressionProxy.
virtual AssignableDataSource<DataType>::const_reference_t RTT::DataObjectInterface< T >::rvalue | ( | ) | const [inline, virtual] |
Get a const reference (or null) to the value of this DataSource.
Getting a reference to an internal data structure is not thread-safe. DataSources which wish to protect their data from concurrent access may return the null reference with this method. All calls to rvalue() must first check whether they do not return null.
Implements RTT::AssignableDataSource< T >.
Definition at line 142 of file DataObjectInterfaces.hpp.
void * RTT::AssignableDataSource< T >::server | ( | int | protocol, | |
void * | arg | |||
) | [inline, virtual, inherited] |
Create an object server which 'mirrors' this DataSource.
Reimplemented from RTT::DataSourceBase.
Reimplemented in RTT::Corba::CORBAAssignableExpression< T >.
Definition at line 79 of file DataSource.inl.
References RTT::TypeInfo::getProtocol(), RTT::DataSource< T >::getTypeInfo(), and RTT::detail::TypeTransporter::server().
virtual int RTT::DataSourceBase::serverProtocol | ( | ) | const [virtual, inherited] |
Inspect if this DataSource is a proxy for a remote server object.
Reimplemented in RTT::Corba::AnyDataSource, RTT::Corba::CORBAExpression< T >, RTT::Corba::CORBAExpression< void >, RTT::Corba::CORBAAssignableExpression< T >, and RTT::Corba::ExpressionProxy.
Referenced by RTT::AssignableDataSource< T >::narrow(), and RTT::DataSource< T >::narrow().
virtual AssignableDataSource<DataType>::reference_t RTT::DataObjectInterface< T >::set | ( | ) | [inline, virtual] |
Get a reference (or null) to the value of this DataSource.
Getting a reference to an internal data structure is not thread-safe. DataSources which wish to protect their data from concurrent access may return the null reference with this method. All calls to set() must first check whether they do not return null.
Implements RTT::AssignableDataSource< T >.
Definition at line 136 of file DataObjectInterfaces.hpp.
virtual void RTT::DataObjectInterface< T >::Set | ( | const DataType & | push | ) | [pure virtual] |
Set the data to a certain value.
push | The data which must be set. |
Implemented in RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, and RTT::DataObject< T >.
std::string RTT::DataSourceBase::toString | ( | ) | [inherited] |
Get the contents of this object as a string.
bool RTT::AssignableDataSource< T >::update | ( | DataSourceBase * | other | ) | [inline, virtual, inherited] |
Update the value of this DataSource with the value of an other DataSource.
Update does a full update of the value, adding extra information if necessary.
Reimplemented from RTT::DataSourceBase.
Definition at line 131 of file DataSource.inl.
References RTT::DataSource< T >::get().
bool RTT::AssignableDataSource< T >::updateBlob | ( | int | protocol, | |
const void * | data | |||
) | [inline, virtual, inherited] |
Updates the value of this DataSource with the value of a transportable data object.
any | The value to update to. |
Reimplemented from RTT::DataSourceBase.
Definition at line 67 of file DataSource.inl.
References RTT::TypeInfo::getProtocol(), RTT::DataSource< T >::getTypeInfo(), and RTT::detail::TypeTransporter::updateBlob().
Referenced by RTT::Corba::CorbaBufferProxy< T >::front(), RTT::Corba::CorbaDataObjectProxy< T >::Get(), RTT::Corba::ExpressionProxy::NarrowAssignableDataSource(), and RTT::Corba::ExpressionProxy::NarrowDataSource().
CommandInterface * RTT::AssignableDataSource< T >::updateCommand | ( | DataSourceBase * | other | ) | [inline, virtual, inherited] |
Generate a CommandInterface object which will update this DataSource with the value of another DataSource when execute()'ed.
Reimplemented from RTT::DataSourceBase.
Reimplemented in RTT::Corba::CORBAAssignableExpression< T >, and RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >.
Definition at line 142 of file DataSource.inl.
Referenced by RTT::Property< bool >::refreshCommand().
virtual bool RTT::DataSourceBase::updatePart | ( | DataSourceBase * | part, | |
DataSourceBase * | other | |||
) | [virtual, inherited] |
Update part of the value of this DataSource with the value of an other DataSource.
Update does a partial update of the value, according to part, which is most likely an index or hash value of some type.
Reimplemented in RTT::detail::AssignableDataSourceAdaptor< To const &, To >.
Referenced by RTT::detail::AssignableDataSourceAdaptor< To const &, To >::updatePart().
virtual CommandInterface* RTT::DataSourceBase::updatePartCommand | ( | DataSourceBase * | part, | |
DataSourceBase * | other | |||
) | [virtual, inherited] |
Generate a CommandInterface object which will partially update this DataSource with the value of another DataSource when execute()'ed.
part is an index or hash value of some type.
Reimplemented in RTT::Corba::CORBAAssignableExpression< T >, RTT::detail::AssignableDataSourceAdaptor< To const &, To >, and RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >.
Referenced by RTT::detail::AssignableDataSourceAdaptor< To const &, To >::updatePartCommand().
std::ostream& RTT::DataSourceBase::write | ( | std::ostream & | os | ) | [inherited] |
Stream the contents of this object.
OS::AtomicInt RTT::DataSourceBase::refcount [mutable, protected, inherited] |
We keep the refcount ourselves.
We aren't using boost::shared_ptr, because boost::intrusive_ptr is better, exactly because it can be used with refcounts that are stored in the class itself. Advantages are that the shared_ptr's for derived classes use the same refcount, which is of course very much desired, and that refcounting happens in an efficient way, which is also nice :)
Definition at line 89 of file DataSourceBase.hpp.