DataObject Class Template Reference

#include </home/sspr/src/www/orocos-1.0/export/build/orocos-rtt-1.2.2/build/rtt/DataObjectInterfaces.hpp>

Inheritance diagram for DataObject:

DataObjectInterface AssignableDataSource DataSource DataSourceBase List of all members.

Detailed Description

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

A class which provides unchecked access to one typed element of data.

It is the most simple form of the DataObjectInterface implementation and hence also the fastest. It is however not thread safe.


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

 DataObject (const std::string &_name, const T &initial_value=T())
 Construct a DataObject by name.
const std::string & getName () const
 Return the name of this DataObject.
void setName (const std::string &_name)
void Get (DataType &pull) const
 Get a copy of the Data of the module.
DataType Get () const
 Get a copy of the data of the module.
void Set (const DataType &push)
 Set the data to a certain value.
DataObject< DataType > * clone () const
 Return a shallow clone of this DataSource.
DataObject< 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 bool update (const CORBA::Any &any)
 Updates the value of this DataSource with the value of a CORBA Any object.
virtual CommandInterfaceupdateCommand (DataSourceBase *other)
 Generate a CommandInterface object which will update this DataSource with the value of another DataSource when execute()'ed.
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 TypeInfogetTypeInfo () const
 Return the Orocos type info object.
virtual std::string getTypeName () const
 Return the Orocos type name, without const, pointer or reference qualifiers.
virtual CORBA::Any * createAny ()
 Creates a CORBA Any object with the current value of this DataSource.
virtual CORBA::Any * getAny ()
 Creates a CORBA Any object with the current value of this DataSource.
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 CommandInterfaceupdatePartCommand (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.

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 TypeInfoGetTypeInfo ()
 Return the Orocos type info.
static std::string GetTypeName ()
 Return the Orocos type name, without const, pointer or reference qualifiers.

Protected Attributes

oro_atomic_t refcount
 We keep the refcount ourselves.


Constructor & Destructor Documentation

DataObject ( const std::string &  _name,
const T &  initial_value = T() 
) [inline]

Construct a DataObject by name.

Parameters:
_name The name of this DataObject.


Member Function Documentation

const std::string& getName (  )  const [inline, virtual]

Return the name of this DataObject.

Returns:
The name

Implements DataObjectInterface.

void Get ( DataType pull  )  const [inline, virtual]

Get a copy of the Data of the module.

Parameters:
pull A copy of the data.

Implements DataObjectInterface.

DataType Get (  )  const [inline, virtual]

Get a copy of the data of the module.

Returns:
The result of the module.

Implements DataObjectInterface.

void Set ( const DataType push  )  [inline, virtual]

Set the data to a certain value.

Parameters:
push The data which must be set.

Implements DataObjectInterface.

DataObject<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.

DataObject<DataType>* copy ( std::map< const DataSourceBase *, DataSourceBase * > &   )  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.

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.

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.

bool update ( DataSourceBase other  )  [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.

Returns:
false if the DataSources are of different type OR if the contents of this DataSource can not be updated.

Reimplemented from DataSourceBase.

bool update ( const CORBA::Any &  any  )  [virtual, inherited]

Updates the value of this DataSource with the value of a CORBA Any object.

Parameters:
any The value to update to.
Returns:
true if any had the correct type.

Reimplemented from DataSourceBase.

CommandInterface * updateCommand ( DataSourceBase other  )  [virtual, inherited]

Generate a CommandInterface object which will update this DataSource with the value of another DataSource when execute()'ed.

Returns:
zero if the DataSource types do not match OR if the contents of this DataSource can not be updated.

Reimplemented from DataSourceBase.

Reimplemented in IndexedValueDataSource.

bool evaluate (  )  const [virtual, inherited]

Force an evaluation of the DataSourceBase.

Returns:
true on successful evaluation. If the DataSource itself contains a boolean, return that boolean.

Implements DataSourceBase.

CORBA::Any * createAny (  )  [virtual, inherited]

Creates a CORBA Any object with the current value of this DataSource.

This does not trigger the evaluation() of this data source.

Returns:
a valid Any object or nill if this type is not supported.

Implements DataSourceBase.

CORBA::Any * getAny (  )  [virtual, inherited]

Creates a CORBA Any object with the current value of this DataSource.

This does trigger the evaluation() of this data source.

Returns:
a valid Any object or nill if this type is not supported.

Implements DataSourceBase.

virtual 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.

Returns:
false if the DataSources are of different type OR if the contents of this DataSource can not be partially updated.

virtual 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.

Returns:
zero if the DataSource types do not match OR if the contents of this DataSource can not be partially updated.

Reimplemented in IndexedValueDataSource.

std::ostream& write ( std::ostream &  os  )  [inherited]

Stream the contents of this object.

See also:
TypeInfo

std::string toString (  )  [inherited]

Get the contents of this object as a string.

See also:
TypeInfo

bool decomposeType ( PropertyBag targetbag  )  [inherited]

Decompose the contents of this object into properties.

See also:
TypeInfo

bool composeType ( DataSourceBase::shared_ptr  source  )  [inherited]

Compose the contents of this object from another datasource.

See also:
TypeInfo


Member Data Documentation

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 :)


The documentation for this class was generated from the following file:
Generated on Fri Oct 19 16:27:23 2007 for Orocos by  doxygen 1.5.1