Orocos Real-Time Toolkit
2.5.0
|
Calculates an offset to an element in memory, based on a type size and an index. More...
#include <rtt/internal/OffsetPartDataSource.hpp>
Public Types | |
typedef unsigned int | offset_type |
typedef boost::intrusive_ptr < OffsetDataSource > | shared_ptr |
Use this type to store a pointer to a DataSourceBase. | |
typedef unsigned int | value_t |
The bare type of T is extracted into value_t. | |
typedef unsigned int | result_t |
typedef details::GetConstRef < unsigned int >::type | const_reference_t |
typedef boost::intrusive_ptr < const DataSource< unsigned int > > | const_ptr |
Use this type to store a const pointer to a DataSourceBase. | |
Public Member Functions | |
OffsetDataSource (offset_type size, DataSource< unsigned int >::shared_ptr index, DataSource< offset_type >::shared_ptr parent_offset) | |
The offset is size times the index plus any parent offset. | |
DataSource< offset_type >::result_t | get () const |
Return the data as type T. | |
DataSource< offset_type >::result_t | value () const |
Return the result of the last evaluate() function. | |
DataSource< offset_type > ::const_reference_t | rvalue () const |
Get a const reference to the value of this DataSource. | |
virtual OffsetDataSource * | clone () const |
Return a shallow clone of this DataSource. | |
virtual OffsetDataSource * | copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &replace) const |
Create a deep copy of this internal::DataSource, unless it is already cloned. | |
BOOST_STATIC_ASSERT (!details::HasConst< unsigned int >::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::TypeInfo * | getTypeInfo () 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 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 ActionInterface * | updateAction (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::TypeInfo * | GetTypeInfo () |
Return the Orocos type info. | |
static std::string | GetTypeName () |
Return the Orocos type name, without const, pointer or reference qualifiers. | |
static DataSource< unsigned int > * | 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. |
Calculates an offset to an element in memory, based on a type size and an index.
OffsetDataSources can be chained one to the other, in order to locate subsequences of subsequences. This data source is used in conjunction with OffsetPartDataSource or other data sources in ordert to manipulate a (sub)element in a (sub)sequence somewhere in memory. Setting this structure up is intricate and only meant for expert type system developers.
Definition at line 56 of file OffsetPartDataSource.hpp.
RTT::internal::OffsetDataSource::OffsetDataSource | ( | offset_type | size, |
DataSource< unsigned int >::shared_ptr | index, | ||
DataSource< offset_type >::shared_ptr | parent_offset | ||
) | [inline] |
The offset is size times the index plus any parent offset.
size | The size of the element referenced to by index. |
index | Datasource pointing to the index for use in operator[] |
parent_offset | The offset to which the parent may be subject itself. |
Definition at line 72 of file OffsetPartDataSource.hpp.
virtual OffsetDataSource* RTT::internal::OffsetDataSource::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< unsigned int >.
Definition at line 97 of file OffsetPartDataSource.hpp.
References OffsetDataSource().
virtual OffsetDataSource* RTT::internal::OffsetDataSource::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< unsigned int >.
Definition at line 101 of file OffsetPartDataSource.hpp.
References RTT::internal::DataSource< T >::copy(), and OffsetDataSource().
virtual bool RTT::internal::DataSource< unsigned int >::evaluate | ( | ) | const [virtual, inherited] |
Force an evaluation of the DataSourceBase.
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.
member_name | The name of the member to get access to. |
Definition at line 124 of file DataSource.cpp.
References RTT::types::TypeInfo::getMember(), and RTT::base::DataSourceBase::getTypeInfo().
DataSourceBase::shared_ptr RTT::DataSourceBase::getMember | ( | DataSourceBase::shared_ptr | member_id, |
DataSourceBase::shared_ptr | offset | ||
) | [virtual, inherited] |
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().
DataSourceBase::shared_ptr RTT::DataSourceBase::getParent | ( | ) | [virtual, inherited] |
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.
void * RTT::DataSourceBase::getRawPointer | ( | ) | [virtual, inherited] |
Returns a pointer to the sample contained in this data source, if there is any, and if it is an lvalue.
Returns 0 otherwise
Reimplemented in RTT::internal::AssignableDataSource< T >, RTT::internal::AssignableDataSource< ProgramInterfacePtr >, RTT::internal::AssignableDataSource< DataSourceType >, RTT::internal::AssignableDataSource< types::carray< T > >, RTT::internal::AssignableDataSource< remove_cr< boost::function_traits< Signature >::result_type >::type >, RTT::internal::AssignableDataSource< ds_type >, RTT::internal::AssignableDataSource< value_t >, RTT::internal::AssignableDataSource< ProgramInterface * >, RTT::internal::AssignableDataSource< bool >, and RTT::internal::AssignableDataSource< StateMachinePtr >.
Definition at line 115 of file DataSource.cpp.
bool RTT::DataSourceBase::isAssignable | ( | ) | const [virtual, inherited] |
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 in RTT::internal::AssignableDataSource< T >, RTT::internal::AssignableDataSource< ProgramInterfacePtr >, RTT::internal::AssignableDataSource< DataSourceType >, RTT::internal::AssignableDataSource< types::carray< T > >, RTT::internal::AssignableDataSource< remove_cr< boost::function_traits< Signature >::result_type >::type >, RTT::internal::AssignableDataSource< ds_type >, RTT::internal::AssignableDataSource< value_t >, RTT::internal::AssignableDataSource< ProgramInterface * >, RTT::internal::AssignableDataSource< bool >, and RTT::internal::AssignableDataSource< StateMachinePtr >.
Definition at line 104 of file DataSource.cpp.
DataSource<offset_type>::const_reference_t RTT::internal::OffsetDataSource::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.
Implements RTT::internal::DataSource< unsigned int >.
Definition at line 92 of file OffsetPartDataSource.hpp.
DataSourceBase::const_ptr RTT::DataSourceBase::stack_const_ptr | ( | const DataSourceBase * | dsb | ) | [static, inherited] |
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().
DataSourceBase::shared_ptr RTT::DataSourceBase::stack_shared_ptr | ( | DataSourceBase * | dsb | ) | [static, inherited] |
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.
Definition at line 98 of file DataSource.cpp.
bool RTT::DataSourceBase::update | ( | DataSourceBase * | other | ) | [virtual, inherited] |
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.
Reimplemented in RTT::internal::AssignableDataSource< T >, RTT::internal::AssignableDataSource< ProgramInterfacePtr >, RTT::internal::AssignableDataSource< DataSourceType >, RTT::internal::AssignableDataSource< types::carray< T > >, RTT::internal::AssignableDataSource< remove_cr< boost::function_traits< Signature >::result_type >::type >, RTT::internal::AssignableDataSource< ds_type >, RTT::internal::AssignableDataSource< value_t >, RTT::internal::AssignableDataSource< ProgramInterface * >, RTT::internal::AssignableDataSource< bool >, and RTT::internal::AssignableDataSource< StateMachinePtr >.
Definition at line 108 of file DataSource.cpp.
ActionInterface * RTT::DataSourceBase::updateAction | ( | DataSourceBase * | other | ) | [virtual, inherited] |
Generate a ActionInterface object which will update this internal::DataSource with the value of another internal::DataSource when execute()'ed.
Reimplemented in RTT::internal::AssignableDataSource< T >, RTT::internal::AssignableDataSource< ProgramInterfacePtr >, RTT::internal::AssignableDataSource< DataSourceType >, RTT::internal::AssignableDataSource< types::carray< T > >, RTT::internal::AssignableDataSource< remove_cr< boost::function_traits< Signature >::result_type >::type >, RTT::internal::AssignableDataSource< ds_type >, RTT::internal::AssignableDataSource< value_t >, RTT::internal::AssignableDataSource< ProgramInterface * >, RTT::internal::AssignableDataSource< bool >, and RTT::internal::AssignableDataSource< StateMachinePtr >.
Definition at line 120 of file DataSource.cpp.
DataSource<offset_type>::result_t RTT::internal::OffsetDataSource::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< unsigned int >.
Definition at line 87 of file OffsetPartDataSource.hpp.
std::ostream & RTT::DataSourceBase::write | ( | std::ostream & | os | ) | [inherited] |
Stream the contents of this object.
Definition at line 91 of file DataSource.cpp.
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().