Orocos Real-Time Toolkit  2.6.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
RTT::internal::NArityDataSource< function > Class Template Reference

A generic N-arity composite DataSource. More...

#include <rtt/internal/DataSources.hpp>

Inheritance diagram for RTT::internal::NArityDataSource< function >:
RTT::internal::DataSource< remove_cr< function::result_type >::type > RTT::base::DataSourceBase

List of all members.

Public Types

typedef boost::intrusive_ptr
< NArityDataSource< function > > 
shared_ptr
 Use this type to store a pointer to a DataSourceBase.
typedef remove_cr
< function::result_type >
::type 
result_t
typedef details::GetConstRef
< remove_cr
< function::result_type >
::type >::type 
const_reference_t
typedef boost::intrusive_ptr
< const DataSource< remove_cr
< function::result_type >
::type > > 
const_ptr
 Use this type to store a const pointer to a DataSourceBase.

Public Member Functions

 NArityDataSource (function f=function())
 Create a DataSource which returns the return value of a function f.
 NArityDataSource (function f, const std::vector< typename DataSource< arg_t >::shared_ptr > &dsargs)
 Create a DataSource which returns the return value of a function f.
void add (typename DataSource< arg_t >::shared_ptr ds)
virtual value_t get () const
 Return the data as type T.
virtual value_t value () const
 Return the result of the last evaluate() function.
DataSource< value_t >
::const_reference_t 
rvalue () const
 Get a const reference to the value of this DataSource.
virtual void reset ()
 Reset the data to initial values.
virtual NArityDataSource
< function > * 
clone () const
 Return a shallow clone of this DataSource.
virtual NArityDataSource
< function > * 
copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
 Create a deep copy of this internal::DataSource, unless it is already cloned.
 BOOST_STATIC_ASSERT (!details::HasConst< remove_cr< function::result_type >::type >::value)
 If you get a compile error here, it means T has const or reference qualifiers, which is not allowed for DataSource<T>
void const * getRawConstPointer ()
 Generic implementation of getRawConstPointer() based on rvalue()
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 types::TypeInfogetTypeInfo () 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 bool isAssignable () const
 Returns true if this object can be cast to an AssignableDataSource.
virtual void updated ()
 In case the internal::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 internal::DataSource with the value of an other DataSource.
virtual ActionInterfaceupdateAction (DataSourceBase *other)
 Generate a ActionInterface object which will update this internal::DataSource with the value of another internal::DataSource when execute()'ed.
virtual shared_ptr getMember (const std::string &member_name)
 Get a (const) reference data source to a member of the structure of this data source.
virtual shared_ptr getMember (DataSourceBase::shared_ptr member_id, DataSourceBase::shared_ptr offset)
 Same as above, but with run-time lookup of the member to use.
virtual std::vector< std::string > getMemberNames () const
 Returns the names of all members of the structure contained in this data source, or an empty list if none.
virtual shared_ptr getParent ()
 Returns the top level data source that contains the full data structure this data source refers to.
std::ostream & write (std::ostream &os)
 Stream the contents of this object.
std::string toString ()
 Get the contents of this object as a string.
virtual void * getRawPointer ()
 Returns a pointer to the sample contained in this data source, if there is any, and if it is an lvalue.

Static Public Member Functions

static std::string GetType ()
 Return usefull type info in a human readable format.
static const types::TypeInfoGetTypeInfo ()
 Return the Orocos type info.
static std::string GetTypeName ()
 Return the Orocos type name, without const, pointer or reference qualifiers.
static DataSource< remove_cr
< function::result_type >
::type > * 
narrow (base::DataSourceBase *db)
 This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object.
static shared_ptr stack_shared_ptr (DataSourceBase *dsb)
 Returns a shared ptr to a DataSourceBase living on the stack.
static const_ptr stack_const_ptr (const DataSourceBase *dsb)
 Returns a const shared_ptr to a DataSourceBase living on the stack.

Protected Attributes

os::AtomicInt refcount
 We keep the refcount ourselves.

Detailed Description

template<typename function>
class RTT::internal::NArityDataSource< function >

A generic N-arity composite DataSource.

It collects data sources of the same type and passes the values found on to function by means of a std::vector.

Parameters:
functionIs a struct which defines value_t operator()(const std::vector<arg_t>&), where value_t is defined as function::result_type and arg_t is defined as function::argument_type.

Definition at line 809 of file DataSources.hpp.


Member Function Documentation

template<typename function>
virtual NArityDataSource<function>* RTT::internal::NArityDataSource< function >::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 internal::DataSource holds reference to. The clone() function is thus a non-deep copy.

Implements RTT::internal::DataSource< remove_cr< function::result_type >::type >.

Definition at line 868 of file DataSources.hpp.

template<typename function>
virtual NArityDataSource<function>* RTT::internal::NArityDataSource< function >::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  alreadyCloned) const [inline, virtual]

Create a deep copy of this internal::DataSource, unless it is already cloned.

Places the association (parent, clone) in alreadyCloned. If the internal::DataSource is non-copyable (for example it represents the Property of a Task ), this may be returned.

Implements RTT::internal::DataSource< remove_cr< function::result_type >::type >.

Definition at line 873 of file DataSources.hpp.

virtual bool RTT::internal::DataSource< remove_cr< function::result_type >::type >::evaluate ( ) const [virtual, inherited]

Force an evaluation of the DataSourceBase.

Returns:
true on successful evaluation.

Implements RTT::base::DataSourceBase.

DataSourceBase::shared_ptr RTT::DataSourceBase::getMember ( const std::string &  member_name) [virtual, inherited]

Get a (const) reference data source to a member of the structure of this data source.

You must call getMember() in turn on the returned member to access sub-members.

Parameters:
member_nameThe name of the member to get access to.
Returns:
null if the member does not exist, this if member_name.empty(), and a reference data source to the member otherwise.

Definition at line 124 of file DataSource.cpp.

References RTT::types::TypeInfo::getMember(), and RTT::base::DataSourceBase::getTypeInfo().

Same as above, but with run-time lookup of the member to use.

Also takes an optional offset argument which can be used to offset the member in memory. This is necessary when using sequences of sequences. DataSources which are a sequence/offset member themselves must override this function to let the returned member take the offset into account.

Definition at line 130 of file DataSource.cpp.

References RTT::types::TypeInfo::getMember(), and RTT::base::DataSourceBase::getTypeInfo().

vector< string > RTT::DataSourceBase::getMemberNames ( ) const [virtual, inherited]

Returns the names of all members of the structure contained in this data source, or an empty list if none.

If this data source is a sequence, it will not return the allowed index numbers.

Definition at line 134 of file DataSource.cpp.

References RTT::types::TypeInfo::getMemberNames(), and RTT::base::DataSourceBase::getTypeInfo().

Returns the top level data source that contains the full data structure this data source refers to.

Defaults to returning this.

Definition at line 138 of file DataSource.cpp.

void * RTT::DataSourceBase::getRawPointer ( ) [virtual, inherited]
bool RTT::DataSourceBase::isAssignable ( ) const [virtual, inherited]
template<typename function>
DataSource<value_t>::const_reference_t RTT::internal::NArityDataSource< function >::rvalue ( ) const [inline, virtual]

Get a const reference to the value of this DataSource.

You must call evaluate() prior to calling this function in order to get the most recent value of this attribute.

Note:
Getting a reference to an internal data structure is not thread-safe.

Implements RTT::internal::DataSource< remove_cr< function::result_type >::type >.

Definition at line 857 of file DataSources.hpp.

Returns a const shared_ptr to a DataSourceBase living on the stack.

Make sure that the const_ptr does not outlive the stacked element.

Definition at line 74 of file DataSource.cpp.

References RTT::base::DataSourceBase::ref().

Returns a shared ptr to a DataSourceBase living on the stack.

Make sure that the shared_ptr does not outlive the stacked element.

Definition at line 69 of file DataSource.cpp.

References RTT::base::DataSourceBase::ref().

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

Get the contents of this object as a string.

See also:
types::TypeInfo

Definition at line 98 of file DataSource.cpp.

bool RTT::DataSourceBase::update ( DataSourceBase other) [virtual, inherited]
template<typename function>
virtual value_t RTT::internal::NArityDataSource< function >::value ( ) const [inline, virtual]

Return the result of the last evaluate() function.

You must call evaluate() prior to calling this function in order to get the most recent value of this attribute.

Implements RTT::internal::DataSource< remove_cr< function::result_type >::type >.

Definition at line 852 of file DataSources.hpp.

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

Stream the contents of this object.

See also:
types::TypeInfo

Definition at line 91 of file DataSource.cpp.


Member Data Documentation

os::AtomicInt RTT::base::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 88 of file DataSourceBase.hpp.

Referenced by RTT::base::DataSourceBase::deref(), and RTT::base::DataSourceBase::ref().


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