Orocos Real-Time Toolkit  2.5.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
RTT::internal::AssignableDataSource< T > Class Template Reference

A DataSource which has set() methods. More...

#include <rtt/internal/DataSource.hpp>

Inheritance diagram for RTT::internal::AssignableDataSource< T >:
RTT::internal::DataSource< T > RTT::base::DataSourceBase RTT::corba::ValueDataSourceProxy< T > RTT::internal::ActionAliasAssignableDataSource< T > RTT::internal::ArrayDataSource< T > RTT::internal::ArrayPartDataSource< T > RTT::internal::LateReferenceDataSource< T > RTT::internal::OffsetPartDataSource< T > RTT::internal::PartDataSource< T > RTT::internal::ReferenceDataSource< T > RTT::internal::ValueDataSource< T >

List of all members.

Public Types

typedef DataSource< T >::value_t value_t
 The bare type of T is extracted into value_t.
typedef DataSource< T >
::const_reference_t 
const_reference_t
typedef boost::call_traits
< value_t >::param_type 
param_t
typedef boost::call_traits
< value_t >::reference 
reference_t
typedef boost::intrusive_ptr
< AssignableDataSource< T > > 
shared_ptr
 Use this type to store a pointer to an AssignableDataSource.
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

virtual void set (param_t t)=0
 Set this DataSource with a value.
virtual reference_t set ()=0
 Get a reference to the value of this DataSource.
void * getRawPointer ()
 Generic implementation of getRawPointer() based on set()
virtual bool isAssignable () const
 Returns true if this object can be cast to an AssignableDataSource.
virtual bool update (base::DataSourceBase *other)
 Update the value of this internal::DataSource with the value of an other DataSource.
virtual base::ActionInterfaceupdateAction (base::DataSourceBase *other)
 Generate a ActionInterface object which will update this internal::DataSource with the value of another internal::DataSource when execute()'ed.
virtual AssignableDataSource< T > * clone () const =0
 Return a shallow clone of this DataSource.
virtual AssignableDataSource< T > * copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
 Create a deep copy of this internal::DataSource, unless it is already cloned.
 BOOST_STATIC_ASSERT (!details::HasConst< T >::value)
 If you get a compile error here, it means T has const or reference qualifiers, which is not allowed for DataSource<T>
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 const_reference_t rvalue () const =0
 Get a const reference to the value of this DataSource.
void const * getRawConstPointer ()
 Generic implementation of getRawConstPointer() based on rvalue()
template<>
void const * getRawConstPointer ()
 Returns a const pointer to the sample contained in this data source, if there is any.
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 void reset ()
 Reset the data to initial values.
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 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.

Static Public Member Functions

static AssignableDataSource< T > * narrow (base::DataSourceBase *db)
 This method narrows a base::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 types::TypeInfoGetTypeInfo ()
 Return the Orocos type info.
static std::string GetTypeName ()
 Return the Orocos type name, without const, pointer or reference qualifiers.
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 T>
class RTT::internal::AssignableDataSource< T >

A DataSource which has set() methods.

Parameters:
TSee DataSource for the semantics of T.

Definition at line 184 of file DataSource.hpp.


Member Function Documentation

template<typename T>
virtual AssignableDataSource<T>* RTT::internal::AssignableDataSource< T >::clone ( ) const [pure virtual]
template<typename T>
virtual AssignableDataSource<T>* RTT::internal::AssignableDataSource< T >::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  alreadyCloned) const [pure virtual]
template<typename T >
bool RTT::internal::DataSource< T >::evaluate ( ) const [virtual, inherited]
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.

Reimplemented in RTT::internal::OffsetPartDataSource< T >.

Definition at line 138 of file DataSource.cpp.

template<>
void const * RTT::internal::DataSource< void >::getRawConstPointer ( ) [inline, virtual, inherited]

Returns a const pointer to the sample contained in this data source, if there is any.

Returns 0 otherwise

Reimplemented from RTT::base::DataSourceBase.

Definition at line 59 of file DataSource.inl.

template<typename T>
virtual bool RTT::internal::AssignableDataSource< T >::isAssignable ( ) const [inline, virtual]

Returns true if this object can be cast to an AssignableDataSource.

When this method returns true, all update functions below will return as well when valid input is given.

Reimplemented from RTT::base::DataSourceBase.

Definition at line 216 of file DataSource.hpp.

template<typename T>
virtual const_reference_t RTT::internal::DataSource< T >::rvalue ( ) const [pure virtual, inherited]

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.

Implemented in RTT::internal::NArityDataSource< function >, RTT::internal::UnaryDataSource< function >, RTT::internal::BinaryDataSource< function >, RTT::internal::ActionAliasAssignableDataSource< T >, RTT::internal::ActionAliasDataSource< T >, RTT::internal::LateConstReferenceDataSource< T >, RTT::internal::LateConstReferenceDataSource< A >, RTT::internal::LateReferenceDataSource< T >, RTT::internal::LateReferenceDataSource< ds_type >, RTT::internal::FusedMCollectDataSource< Signature >, RTT::internal::ArrayDataSource< T >, RTT::internal::FusedMSendDataSource< Signature >, RTT::internal::AliasDataSource< T >, RTT::internal::FusedMCallDataSource< Signature >, RTT::internal::ReferenceDataSource< T >, RTT::internal::ReferenceDataSource< ds_type >, RTT::internal::OffsetPartDataSource< T >, RTT::internal::ConstReferenceDataSource< T >, RTT::corba::ValueDataSourceProxy< T >, RTT::internal::ConstantDataSource< T >, RTT::internal::ArrayPartDataSource< T >, RTT::internal::PartDataSource< T >, RTT::internal::FusedFunctorDataSource< Signature, Enable >, RTT::corba::DataSourceProxy< T >, RTT::internal::ValueDataSource< T >, RTT::internal::ValueDataSource< ProgramInterfacePtr >, RTT::internal::ValueDataSource< ds_type >, RTT::internal::ValueDataSource< StateMachinePtr >, RTT::internal::OffsetDataSource, RTT::internal::InputPortSource< T >, RTT::corba::AnyDataSource, RTT::scripting::DataSourceTime, RTT::internal::DataSourceCommand, RTT::scripting::DataSourceCondition, and RTT::internal::DataObjectDataSource< T >.

Referenced by RTT::types::PrimitiveTypeInfo< std::vector< T >, use_ostream >::buildConstant(), RTT::types::StdVectorTypeInfo::composeType(), RTT::types::TemplateTypeInfo< T, false >::composeType(), RTT::types::BoostArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::CArrayTypeInfo< T, has_ostream >::composeType(), RTT::types::SequenceTypeInfoBase< std::vector< double > >::composeType(), RTT::types::decomposePropertyBag(), RTT::types::TemplateTypeInfo< T, false >::decomposeType(), RTT::corba::ValueDataSourceProxy< T >::get(), RTT::internal::DataSource< first_arg_t >::getRawConstPointer(), RTT::corba::ValueDataSourceProxy< T >::rvalue(), RTT::Property< bool >::rvalue(), RTT::types::typeDecomposition(), RTT::corba::ValueDataSourceProxy< T >::value(), RTT::types::PrimitiveTypeInfo< std::vector< T >, use_ostream >::write(), and RTT::OutputPort< T >::write().

template<typename T>
virtual reference_t RTT::internal::AssignableDataSource< T >::set ( ) [pure virtual]

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.

template<class T >
bool RTT::internal::AssignableDataSource< T >::update ( base::DataSourceBase other) [virtual]

Update the value of this internal::DataSource with the value of an other DataSource.

Update does a full update of the value, adding extra information if necessary.

Precondition:
this->isAssignable() == true
Returns:
false if the DataSources are of different type OR if the contents of this internal::DataSource can not be updated.

Reimplemented from RTT::base::DataSourceBase.

Definition at line 78 of file DataSource.inl.

References RTT::types::TypeInfo::convert(), RTT::internal::DataSource< T >::evaluate(), RTT::internal::DataSourceTypeInfo< T >::getTypeInfo(), and RTT::internal::DataSource< T >::value().

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

Precondition:
this->isAssignable() == true
Returns:
zero if the internal::DataSource types do not match OR if the contents of this internal::DataSource can not be updated.

Reimplemented from RTT::base::DataSourceBase.

Definition at line 94 of file DataSource.inl.

References RTT::types::TypeInfo::convert(), and RTT::internal::DataSourceTypeInfo< T >::getTypeInfo().

template<typename T>
virtual result_t RTT::internal::DataSource< T >::value ( ) const [pure virtual, inherited]

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.

Implemented in RTT::internal::NArityDataSource< function >, RTT::internal::UnaryDataSource< function >, RTT::internal::BinaryDataSource< function >, RTT::internal::ActionAliasAssignableDataSource< T >, RTT::internal::ActionAliasDataSource< T >, RTT::internal::LateConstReferenceDataSource< T >, RTT::internal::LateConstReferenceDataSource< A >, RTT::internal::FusedMCollectDataSource< Signature >, RTT::internal::LateReferenceDataSource< T >, RTT::internal::LateReferenceDataSource< ds_type >, RTT::internal::ArrayDataSource< T >, RTT::internal::FusedMSendDataSource< Signature >, RTT::internal::AliasDataSource< T >, RTT::internal::FusedMCallDataSource< Signature >, RTT::internal::ReferenceDataSource< T >, RTT::internal::ReferenceDataSource< ds_type >, RTT::internal::ConstReferenceDataSource< T >, RTT::internal::OffsetPartDataSource< T >, RTT::corba::ValueDataSourceProxy< T >, RTT::internal::ConstantDataSource< T >, RTT::internal::ArrayPartDataSource< T >, RTT::internal::FusedFunctorDataSource< Signature, Enable >, RTT::corba::DataSourceProxy< T >, RTT::internal::PartDataSource< T >, RTT::internal::InputPortSource< T >, RTT::internal::OffsetDataSource, RTT::internal::ValueDataSource< T >, RTT::internal::ValueDataSource< ProgramInterfacePtr >, RTT::internal::ValueDataSource< ds_type >, RTT::internal::ValueDataSource< StateMachinePtr >, RTT::corba::AnyDataSource, RTT::internal::DataSourceCommand, RTT::scripting::DataSourceCondition, RTT::scripting::DataSourceTime, and RTT::internal::DataObjectDataSource< T >.

Referenced by RTT::scripting::CommandDataSourceBool::execute(), RTT::scripting::EvalCommand::execute(), RTT::internal::AssignableDataSource< T >::update(), RTT::corba::ValueDataSourceProxy< T >::updated(), and RTT::types::BoolTypeInfo::write().

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