Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | Public Attributes | List of all members
RTT::base::DataObject< T > Class Template Reference

This object represents the default thread-safe data object implementation used by Orocos objects. More...

#include <rtt/base/DataObject.hpp>

Inheritance diagram for RTT::base::DataObject< T >:
RTT::base::DataObjectLockFree< T > RTT::base::DataObjectInterface< T > RTT::base::DataObjectBase

Public Types

typedef T DataType
 The type of the data. More...
 
typedef T value_t
 
typedef DataObjectInterface< T >::reference_t reference_t
 
typedef DataObjectInterface< T >::param_t param_t
 
typedef DataObjectBase::Options Options
 
typedef boost::shared_ptr< DataObjectInterface< T > > shared_ptr
 Used for shared_ptr management. More...
 

Public Member Functions

 DataObject (const T &initial_value=T())
 Create a data object for holding a user defined struct. More...
 
virtual value_t Get () const
 Get a copy of the data. More...
 
virtual FlowStatus Get (reference_t pull, bool copy_old_data, bool copy_sample) const
 Get a copy of the Data (non allocating). More...
 
virtual FlowStatus Get (reference_t pull, bool copy_old_data=true) const
 Get a copy of the Data (non allocating). More...
 
virtual bool Set (param_t push)
 Set the data to a certain value (non blocking). More...
 
virtual bool data_sample (param_t sample, bool reset=true)
 Provides a data sample to initialize this data object. More...
 
virtual value_t data_sample () const
 Reads back a data sample. More...
 
virtual void clear ()
 Clears any data stored by this data object, so that any subsequent Get() without a new Set() will return NoData. More...
 

Public Attributes

const unsigned int MAX_THREADS
 The maximum number of threads. More...
 

Detailed Description

template<class T>
class RTT::base::DataObject< T >

This object represents the default thread-safe data object implementation used by Orocos objects.

Definition at line 65 of file DataObject.hpp.

Member Typedef Documentation

template<class T >
typedef T RTT::base::DataObject< T >::DataType

The type of the data.

Definition at line 76 of file DataObject.hpp.

template<class T >
typedef DataObjectBase::Options RTT::base::DataObjectLockFree< T >::Options
inherited

Definition at line 88 of file DataObjectLockFree.hpp.

template<class T >
typedef DataObjectInterface<T>::param_t RTT::base::DataObjectLockFree< T >::param_t
inherited

Definition at line 86 of file DataObjectLockFree.hpp.

template<class T >
typedef DataObjectInterface<T>::reference_t RTT::base::DataObjectLockFree< T >::reference_t
inherited

Definition at line 85 of file DataObjectLockFree.hpp.

template<class T>
typedef boost::shared_ptr<DataObjectInterface<T> > RTT::base::DataObjectInterface< T >::shared_ptr
inherited

Used for shared_ptr management.

Definition at line 68 of file DataObjectInterface.hpp.

template<class T >
typedef T RTT::base::DataObject< T >::value_t

Definition at line 77 of file DataObject.hpp.

Constructor & Destructor Documentation

template<class T >
RTT::base::DataObject< T >::DataObject ( const T &  initial_value = T())
inline

Create a data object for holding a user defined struct.

Definition at line 83 of file DataObject.hpp.

Member Function Documentation

template<class T >
virtual void RTT::base::DataObjectLockFree< T >::clear ( )
inlinevirtualinherited

Clears any data stored by this data object, so that any subsequent Get() without a new Set() will return NoData.

Implements RTT::base::DataObjectInterface< T >.

Definition at line 337 of file DataObjectLockFree.hpp.

References RTT::os::CAS(), RTT::NoData, oro_atomic_dec(), and oro_atomic_inc().

template<class T >
virtual bool RTT::base::DataObjectLockFree< T >::data_sample ( param_t  sample,
bool  reset = true 
)
inlinevirtualinherited

Provides a data sample to initialize this data object.

As such enough storage space can be allocated before the actual writing begins.

Parameters
samplethe data sample
resetenforce reinitialization even if this operation clears the stored data.
Returns
true if the data object was successfully (re)initialized.

Implements RTT::base::DataObjectInterface< T >.

Definition at line 310 of file DataObjectLockFree.hpp.

References RTT::NoData.

template<class T >
virtual value_t RTT::base::DataObjectLockFree< T >::data_sample ( ) const
inlinevirtualinherited
template<class T >
virtual value_t RTT::base::DataObjectLockFree< T >::Get ( ) const
inlinevirtualinherited

Get a copy of the data.

This method will allocate memory twice if data is not a value type. Use Get(reference_t) for the non-allocating version.

Returns
A copy of the data.

Implements RTT::base::DataObjectInterface< T >.

Definition at line 181 of file DataObjectLockFree.hpp.

Referenced by RTT::base::DataObjectLockFree< T >::data_sample(), and RTT::base::DataObjectLockFree< T >::Get().

template<class T >
virtual FlowStatus RTT::base::DataObjectLockFree< T >::Get ( reference_t  pull,
bool  copy_old_data,
bool  copy_sample 
) const
inlinevirtualinherited

Get a copy of the Data (non allocating).

If pull has reserved enough memory to store the copy, no memory will be allocated.

Parameters
pullA copy of the data.
copy_old_dataIf true, also copy the data if the data object has not been updated since the last call.
copy_sampleIf true, copy the data unconditionally.

Definition at line 197 of file DataObjectLockFree.hpp.

References RTT::os::CAS(), RTT::NewData, RTT::NoData, RTT::OldData, oro_atomic_dec(), and oro_atomic_inc().

template<class T >
virtual FlowStatus RTT::base::DataObjectLockFree< T >::Get ( reference_t  pull,
bool  copy_old_data = true 
) const
inlinevirtualinherited

Get a copy of the Data (non allocating).

If pull has reserved enough memory to store the copy, no memory will be allocated.

Parameters
pullA copy of the data.
copy_old_dataIf true, also copy the data if the data object has not been updated since the last call.

Implements RTT::base::DataObjectInterface< T >.

Definition at line 245 of file DataObjectLockFree.hpp.

References RTT::base::DataObjectLockFree< T >::Get().

template<class T >
virtual bool RTT::base::DataObjectLockFree< T >::Set ( param_t  push)
inlinevirtualinherited

Set the data to a certain value (non blocking).

Parameters
pushThe data which must be set.

Implements RTT::base::DataObjectInterface< T >.

Definition at line 255 of file DataObjectLockFree.hpp.

References RTT::base::DataObjectLockFree< T >::data_sample(), RTT::Error, RTT::internal::DataSourceTypeInfo< T >::getType(), RTT::NewData, oro_atomic_dec(), oro_atomic_inc_and_test(), and oro_atomic_read().

Member Data Documentation

template<class T >
const unsigned int RTT::base::DataObjectLockFree< T >::MAX_THREADS
inherited

The maximum number of threads.

Definition at line 93 of file DataObjectLockFree.hpp.


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