#include <rtt/DataObjectInterfaces.hpp>

When there are more writes than reads, the last write will be returned. The internal buffer can get full if too many concurrent reads are taking to long. In that case, each new read will read the element the previous read returned.
* The following Truth table applies when a Low Priority thread is
* preempted by a High Priority thread :
*
* L\H | Set | Get |
* Set | Ok | Ok |
* Get | Ok | Ok |
*
* legend : L : Low Priority thread
* H : High Priority thread
* Blk: Blocks High Priority thread (bad!)
* NA : Not allowed !
* Definition at line 480 of file DataObjectInterfaces.hpp.
Public Types | |
| typedef T | DataType |
| The type of the data. | |
|
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 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 | |
| DataObjectLockFree (const std::string &_name, const T &initial_value=T()) | |
| Construct a DataObjectLockFree by name. | |
| const std::string & | getName () const |
| Return the name of this DataObject. | |
| void | setName (const std::string &_name) |
| DataType | Get () const |
| Get a copy of the data. | |
| void | Get (DataType &pull) const |
| Get a copy of the Data (non allocating). | |
| void | Set (const DataType &push) |
| Set the data to a certain value (non blocking). | |
| DataObjectLockFree < DataType > * | clone () const |
| Return a shallow clone of this DataSource. | |
| DataObjectLockFree < DataType > * | copy (std::map< const DataSourceBase *, DataSourceBase * > &) const |
| Create a deep copy of this DataSource, unless it is already cloned. | |
| 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 void | set (param_t t)=0 |
| Set this DataSource with a value. | |
| virtual AssignableDataSource < DataType > ::const_reference_t | rvalue () const |
| Get a const reference (or null) to the value of this DataSource. | |
| 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 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. | |
| 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. | |
Static Public Attributes | |
| static const unsigned int | MAX_THREADS = 8 |
Protected Attributes | |
| oro_atomic_t | refcount |
| We keep the refcount ourselves. | |
| DataObjectLockFree | ( | const std::string & | _name, | |
| const T & | initial_value = T() | |||
| ) | [inline] |
Construct a DataObjectLockFree by name.
| _name | The name of this DataObject. | |
| initial_value | The initial value of this DataObject. |
Definition at line 542 of file DataObjectInterfaces.hpp.
| const std::string& getName | ( | ) | const [inline, virtual] |
Return the name of this DataObject.
Implements DataObjectInterface.
Definition at line 560 of file DataObjectInterfaces.hpp.
| DataType Get | ( | ) | const [inline, virtual] |
Get a copy of the data.
This method will allocate memory twice if data is not a value type. Use Get(DataType&) for the non-allocating version.
Implements DataObjectInterface.
Definition at line 574 of file DataObjectInterfaces.hpp.
| void Get | ( | DataType & | pull | ) | const [inline, virtual] |
Get a copy of the Data (non allocating).
If pull has reserved enough memory to store the copy, no memory will be allocated.
| pull | A copy of the data. |
Implements DataObjectInterface.
Definition at line 583 of file DataObjectInterfaces.hpp.
| void Set | ( | const DataType & | push | ) | [inline, virtual] |
Set the data to a certain value (non blocking).
| push | The data which must be set. |
This method can not be called concurrently (only one producer). With a minimum of 3 buffers, if the write_ptr+1 field is not occupied, it will remain so because the read_ptr is at write_ptr-1 (and can not increment the counter on write_ptr+1). Hence, no locking is needed.
Implements DataObjectInterface.
Definition at line 608 of file DataObjectInterfaces.hpp.
| DataObjectLockFree<DataType>* clone | ( | ) | const [inline, virtual] |
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 AssignableDataSource.
Definition at line 635 of file DataObjectInterfaces.hpp.
| DataObjectLockFree<DataType>* copy | ( | std::map< const DataSourceBase *, DataSourceBase * > & | alreadyCloned | ) | const [inline, virtual] |
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 AssignableDataSource.
Definition at line 639 of file DataObjectInterfaces.hpp.
| virtual AssignableDataSource<DataType>::reference_t set | ( | ) | [inline, virtual, inherited] |
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 AssignableDataSource.
Definition at line 136 of file DataObjectInterfaces.hpp.
| virtual AssignableDataSource<DataType>::const_reference_t rvalue | ( | ) | const [inline, virtual, inherited] |
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 AssignableDataSource.
Definition at line 142 of file DataObjectInterfaces.hpp.
| bool 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 DataSourceBase.
Definition at line 131 of file DataSource.inl.
References DataSource::get().
| CommandInterface * 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 DataSourceBase.
Reimplemented in CORBAAssignableExpression, and IndexedValueDataSource.
Definition at line 142 of file DataSource.inl.
Referenced by CORBAAssignableExpression::updateCommand().
| bool 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 DataSourceBase.
Definition at line 67 of file DataSource.inl.
References TypeInfo::getProtocol(), DataSource::getTypeInfo(), and TypeTransporter::updateBlob().
Referenced by CorbaBufferProxy::front(), CORBAExpression::get(), CorbaDataObjectProxy::Get(), ExpressionProxy::NarrowAssignableDataSource(), ExpressionProxy::NarrowDataSource(), and CorbaBufferProxy::Pop().
| void * server | ( | int | protocol, | |
| void * | arg | |||
| ) | [inline, virtual, inherited] |
Create an object server which 'mirrors' this DataSource.
Reimplemented from DataSourceBase.
Reimplemented in CORBAAssignableExpression.
Definition at line 79 of file DataSource.inl.
References TypeInfo::getProtocol(), DataSource::getTypeInfo(), and TypeTransporter::server().
| bool evaluate | ( | ) | const [inline, virtual, inherited] |
Force an evaluation of the DataSourceBase.
Implements DataSourceBase.
Definition at line 52 of file DataSource.inl.
Referenced by EvalCommand::readArguments(), FunctorImpl< 4, FunctionT >::readArguments(), FunctorImpl< 3, FunctionT >::readArguments(), FunctorImpl< 2, FunctionT >::readArguments(), FunctorImpl< 1, FunctionT >::readArguments(), FunctorDS1::readArguments(), and CommandDataSourceBool::readArguments().
| bool 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.
Definition at line 101 of file DataSource.cpp.
| CommandInterface * 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 CORBAAssignableExpression, and IndexedValueDataSource.
Definition at line 105 of file DataSource.cpp.
Referenced by CORBAAssignableExpression::updatePartCommand().
| std::ostream & write | ( | std::ostream & | os | ) | [inherited] |
| std::string toString | ( | ) | [inherited] |
Get the contents of this object as a string.
Definition at line 71 of file DataSource.cpp.
| bool decomposeType | ( | PropertyBag & | targetbag | ) | [inherited] |
Decompose the contents of this object into properties.
Definition at line 77 of file DataSource.cpp.
| bool composeType | ( | DataSourceBase::shared_ptr | source | ) | [inherited] |
Compose the contents of this object from another datasource.
Definition at line 83 of file DataSource.cpp.
| void * 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 ExpressionProxy.
Definition at line 116 of file DataSource.cpp.
References TypeTransporter::createBlob(), TypeInfo::getProtocol(), and DataSourceBase::getTypeInfo().
Referenced by CorbaBufferProxy::Push(), CORBAAssignableExpression::set(), and CorbaDataObjectProxy::Set().
| void * 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 ExpressionProxy.
Definition at line 126 of file DataSource.cpp.
References TypeTransporter::createBlob(), DataSourceBase::evaluate(), TypeInfo::getProtocol(), and DataSourceBase::getTypeInfo().
| int serverProtocol | ( | ) | const [virtual, inherited] |
Inspect if this DataSource is a proxy for a remote server object.
Reimplemented in AnyDataSource, CORBAExpression, CORBAExpression< void >, CORBAAssignableExpression, and ExpressionProxy.
Definition at line 142 of file DataSource.cpp.
Referenced by AssignableDataSource::narrow(), DataSource::narrow(), CorbaTemplateProtocol::narrowAssignableDataSource(), and CorbaTemplateProtocol::narrowDataSource().
| void * method | ( | int | protocol, | |
| MethodC * | orig, | |||
| void * | arg | |||
| ) | [virtual, inherited] |
Create an object server which 'mirrors' this DataSource.
Reimplemented in ExpressionProxy.
Definition at line 157 of file DataSource.cpp.
References TypeInfo::getProtocol(), DataSourceBase::getTypeInfo(), and TypeTransporter::method().
const unsigned int MAX_THREADS = 8 [static] |
The maximum number of threads.
The size of the buffer is for now statically determined, which allows for 7 readers and 1 writer (a total of 8 threads !) This is to be improved, although knowing the max number of threads in a RT application is not so hard.
Definition at line 497 of file DataObjectInterfaces.hpp.
oro_atomic_t 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.
Referenced by DataSourceBase::DataSourceBase(), DataSourceBase::deref(), and DataSourceBase::ref().
1.5.3