RTT::DataSource< T > Class Template Reference

DataSource is a base class representing a generic way to read data of type T. More...

#include <rtt/DataSource.hpp>

Inheritance diagram for RTT::DataSource< T >:
RTT::DataSourceBase RTT::AssignableDataSource< T > RTT::BufferDataSource< T > RTT::ConstantDataSource< T > RTT::Corba::CORBAExpression< T > RTT::Corba::CORBAAssignableExpression< T > RTT::DataObjectInterface< T > RTT::ReferenceDataSource< T > RTT::ValueDataSource< T > RTT::Corba::CorbaDataObject< T > RTT::Corba::CorbaDataObjectProxy< T > RTT::DataObject< T > RTT::DataObjectLocked< T > RTT::DataObjectLockFree< T > RTT::DataObjectPriorityGet< T > RTT::DataObjectPrioritySet< T > RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >

List of all members.

Public Types

typedef boost::remove_const
< typename
boost::remove_reference< T >
::type >::type 
value_t
 The bare type of T is extracted into value_t.
typedef T result_t
typedef boost::intrusive_ptr
< DataSource< T > > 
shared_ptr
 Use this type to store a pointer to a DataSourceBase.
typedef boost::intrusive_ptr
< const DataSource< T > > 
const_ptr
 Use this type to store a const pointer to a DataSourceBase.

Public Member Functions

virtual result_t get () const =0
 Return the data as type T.
virtual result_t value () const =0
 Return the result of the last evaluate() function.
virtual bool evaluate () const
 Force an evaluation of the DataSourceBase.
virtual DataSource< T > * clone () const =0
 Return a shallow clone of this DataSource.
virtual DataSource< T > * copy (std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const =0
 Create a deep copy of this DataSource, unless it is already cloned.
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.
template<>
RTT_API bool evaluate () const
 Force an evaluation of the DataSourceBase.
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 update (DataSourceBase *other)
 Update the value of this DataSource with the value of an other DataSource.
virtual CommandInterfaceupdateCommand (DataSourceBase *other)
 Generate a CommandInterface object which will update this DataSource with the value of another DataSource when execute()'ed.
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.
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 bool updateBlob (int protocol, const void *data)
 Updates the value of this DataSource with the value of a transportable data object.
virtual int serverProtocol () const
 Inspect if this DataSource is a proxy for a remote server object.
virtual void * server (int protocol, void *arg)
 Create an object server which 'mirrors' this DataSource.
virtual void * method (int protocol, MethodC *orig, void *arg)
 Create an object server which 'mirrors' this DataSource.

Static Public Member Functions

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.
static DataSource< T > * narrow (DataSourceBase *db)
 This method narrows a DataSourceBase to a typeded DataSource, possibly returning a new object.

Protected Attributes

OS::AtomicInt refcount
 We keep the refcount ourselves.

Detailed Description

template<typename T>
class RTT::DataSource< T >

DataSource is a base class representing a generic way to read data of type T.

See also:
DataSourceBase for shared_ptr use.
Parameters:
T The type of data returned by get(). It does not necessarily say that the data is stored as a T, it only specifies in which form the get() method returns the data. Thus a DataSource<const std::string&> returns a const ref to a string, but may store the string itself by value.

Definition at line 76 of file DataSource.hpp.


Member Function Documentation

template<typename T>
virtual DataSource<T>* RTT::DataSource< T >::clone (  )  const [pure 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 RTT::DataSourceBase.

Implemented in RTT::BufferDataSource< T >, RTT::Corba::AnyDataSource, RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::Corba::CORBAExpression< T >, RTT::Corba::CORBAExpression< void >, RTT::Corba::CORBAAssignableExpression< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, RTT::DataObject< T >, RTT::AssignableDataSource< T >, 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 & >, RTT::detail::AssignableDataSourceAdaptor< To const &, To >, RTT::detail::DataSourceArgsMethod< SignatureT, FunctorT >, RTT::DataSourceCommand, RTT::DataSourceCondition, RTT::ValueDataSource< T >, RTT::ConstantDataSource< T >, RTT::ReferenceDataSource< T >, RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >, RTT::BinaryDataSource< function >, RTT::TernaryDataSource< function >, RTT::SixaryDataSource< function >, RTT::UnaryDataSource< function >, RTT::NArityDataSource< function >, RTT::DataSourceTime, RTT::detail::FunctorDataSource0< FunctorT >, RTT::detail::FunctorDataSourceDS0< ComponentT, FunctorT >, RTT::detail::FunctorDataSourceDS1< ComponentT, FunctorT, Arg1T >, RTT::AssignableDataSource< arg3_type >, RTT::AssignableDataSource< DataSourceType >, RTT::AssignableDataSource< T1 >, RTT::AssignableDataSource< T2 >, RTT::AssignableDataSource< A1 >, RTT::AssignableDataSource< T3 >, RTT::AssignableDataSource< StateMachineWPtr >, RTT::AssignableDataSource< R >, RTT::AssignableDataSource< A2 >, RTT::AssignableDataSource< A >, RTT::AssignableDataSource< A3 >, RTT::AssignableDataSource< arg4_type >, RTT::AssignableDataSource< TFrom >, RTT::AssignableDataSource< From >, RTT::AssignableDataSource< ProgramInterfaceWPtr >, RTT::AssignableDataSource< arg2_type >, RTT::AssignableDataSource< arg1_type >, RTT::AssignableDataSource< ProgramInterface * >, RTT::AssignableDataSource< value_t >, RTT::AssignableDataSource< bool >, RTT::AssignableDataSource< To >, RTT::AssignableDataSource< boost::function_traits< DataType >::result_type >, RTT::AssignableDataSource< TFrom & >, RTT::detail::DataSourceArgsMethod< S >, 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 >, RTT::ValueDataSource< boost::function_traits< DataType >::result_type >, and RTT::detail::FunctorDataSource0< F >.

Referenced by RTT::detail::AssignableDataSourceAdaptor< From, To >::clone(), RTT::detail::DataSourceAdaptor< const TFrom, const TFrom & >::clone(), RTT::detail::DataSourceAdaptor< TFrom, const TFrom & >::clone(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >::clone(), RTT::detail::DataSourceAdaptor< const TFrom &, const TFrom >::clone(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom >::clone(), and RTT::detail::DataSourceAdaptor< From, To >::clone().

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

Compose the contents of this object from another datasource.

See also:
TypeInfo
template<typename T>
virtual DataSource<T>* RTT::DataSource< T >::copy ( std::map< const DataSourceBase *, DataSourceBase * > &  alreadyCloned  )  const [pure 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 RTT::DataSourceBase.

Implemented in RTT::BufferDataSource< T >, RTT::Corba::AnyDataSource, RTT::Corba::CorbaDataObject< T >, RTT::Corba::CorbaDataObjectProxy< T >, RTT::Corba::CORBAExpression< T >, RTT::Corba::CORBAExpression< void >, RTT::Corba::CORBAAssignableExpression< T >, RTT::DataObjectLocked< T >, RTT::DataObjectPrioritySet< T >, RTT::DataObjectPriorityGet< T >, RTT::DataObjectLockFree< T >, RTT::DataObject< T >, RTT::AssignableDataSource< T >, 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 & >, RTT::detail::AssignableDataSourceAdaptor< To const &, To >, RTT::detail::DataSourceArgsMethod< SignatureT, FunctorT >, RTT::DataSourceCommand, RTT::DataSourceCondition, RTT::ValueDataSource< T >, RTT::ConstantDataSource< T >, RTT::ReferenceDataSource< T >, RTT::IndexedValueDataSource< T, Index, SetType, IPred, APred >, RTT::BinaryDataSource< function >, RTT::TernaryDataSource< function >, RTT::SixaryDataSource< function >, RTT::UnaryDataSource< function >, RTT::NArityDataSource< function >, RTT::DataSourceTime, RTT::detail::FunctorDataSource0< FunctorT >, RTT::detail::FunctorDataSourceDS0< ComponentT, FunctorT >, RTT::detail::FunctorDataSourceDS1< ComponentT, FunctorT, Arg1T >, RTT::AssignableDataSource< arg3_type >, RTT::AssignableDataSource< DataSourceType >, RTT::AssignableDataSource< T1 >, RTT::AssignableDataSource< T2 >, RTT::AssignableDataSource< A1 >, RTT::AssignableDataSource< T3 >, RTT::AssignableDataSource< StateMachineWPtr >, RTT::AssignableDataSource< R >, RTT::AssignableDataSource< A2 >, RTT::AssignableDataSource< A >, RTT::AssignableDataSource< A3 >, RTT::AssignableDataSource< arg4_type >, RTT::AssignableDataSource< TFrom >, RTT::AssignableDataSource< From >, RTT::AssignableDataSource< ProgramInterfaceWPtr >, RTT::AssignableDataSource< arg2_type >, RTT::AssignableDataSource< arg1_type >, RTT::AssignableDataSource< ProgramInterface * >, RTT::AssignableDataSource< value_t >, RTT::AssignableDataSource< bool >, RTT::AssignableDataSource< To >, RTT::AssignableDataSource< boost::function_traits< DataType >::result_type >, RTT::AssignableDataSource< TFrom & >, RTT::detail::DataSourceArgsMethod< S >, 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 >, RTT::ValueDataSource< boost::function_traits< DataType >::result_type >, and RTT::detail::FunctorDataSource0< F >.

Referenced by RTT::detail::FunctorDataSourceDS1< ComponentT, FunctorT, Arg1T >::copy(), RTT::detail::FunctorDataSourceDS0< ComponentT, FunctorT >::copy(), RTT::UnaryDataSource< function >::copy(), RTT::SixaryDataSource< function >::copy(), RTT::TernaryDataSource< function >::copy(), RTT::BinaryDataSource< function >::copy(), RTT::detail::AssignableDataSourceAdaptor< From, To >::copy(), RTT::detail::DataSourceAdaptor< const TFrom, const TFrom & >::copy(), RTT::detail::DataSourceAdaptor< TFrom, const TFrom & >::copy(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom & >::copy(), RTT::detail::DataSourceAdaptor< const TFrom &, const TFrom >::copy(), RTT::detail::DataSourceAdaptor< TFrom &, TFrom >::copy(), and RTT::detail::DataSourceAdaptor< From, To >::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.

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

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.

See also:
TypeInfo
template<>
RTT_API bool RTT::DataSource< bool >::evaluate (  )  const [inline, virtual]

Force an evaluation of the DataSourceBase.

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

Implements RTT::DataSourceBase.

template<typename T >
bool RTT::DataSource< T >::evaluate (  )  const [inline, virtual]
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();

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

Reimplemented in RTT::Corba::ExpressionProxy.

virtual void* RTT::DataSourceBase::method ( int  protocol,
MethodC orig,
void *  arg 
) [virtual, inherited]

Create an object server which 'mirrors' this DataSource.

Returns:
The existing server if serverProtocol() == protocol, or a new method object reference otherwise.
See also:
Operations.idl

Reimplemented in RTT::Corba::ExpressionProxy.

virtual void* RTT::DataSourceBase::server ( int  protocol,
void *  arg 
) [virtual, inherited]
virtual int RTT::DataSourceBase::serverProtocol (  )  const [virtual, inherited]

Inspect if this DataSource is a proxy for a remote server object.

Returns:
0 if it is a local DataSource, or the protocol id if it is a proxy for a remove server.

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().

std::string RTT::DataSourceBase::toString (  )  [inherited]

Get the contents of this object as a string.

See also:
TypeInfo
virtual bool RTT::DataSourceBase::update ( DataSourceBase other  )  [virtual, inherited]
virtual bool RTT::DataSourceBase::updateBlob ( int  protocol,
const void *  data 
) [virtual, inherited]
virtual CommandInterface* RTT::DataSourceBase::updateCommand ( DataSourceBase other  )  [virtual, inherited]
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.

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

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.

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

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.

See also:
TypeInfo

Member Data Documentation

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.


The documentation for this class was generated from the following files:
Generated on Thu Dec 23 13:22:41 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3