Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | Protected Attributes | List of all members
RTT::types::BoostArrayTypeInfo< T, has_ostream > Class Template Reference

Template for data types that are of type boost::array<U,int>. More...

#include <rtt/types/BoostArrayTypeInfo.hpp>

Inheritance diagram for RTT::types::BoostArrayTypeInfo< T, has_ostream >:
RTT::types::PrimitiveTypeInfo< T, has_ostream > RTT::types::MemberFactory RTT::types::CompositionFactory RTT::types::TypeInfoGenerator RTT::types::TemplateValueFactory< T > RTT::types::StreamFactory RTT::types::ValueFactory

Public Types

typedef T DataType
 The given T parameter is the type of the DataSources. More...
 

Public Member Functions

 BoostArrayTypeInfo (std::string name)
 
bool installTypeInfoObject (TypeInfo *ti)
 Installs the type info object in the global data source type info handler and adds any additional features to the type info object. More...
 
virtual std::vector< std::string > getMemberNames () const
 Returns the list of struct member names of this type. More...
 
virtual base::DataSourceBase::shared_ptr getMember (base::DataSourceBase::shared_ptr item, const std::string &name) const
 Returns a member of a given data source struct identified by its name. More...
 
virtual base::DataSourceBase::shared_ptr getMember (base::DataSourceBase::shared_ptr item, base::DataSourceBase::shared_ptr id) const
 Returns a member of a given data source identified by a data source id. More...
 
virtual base::DataSourceBase::shared_ptr decomposeType (base::DataSourceBase::shared_ptr source) const
 Use getMember() for decomposition... More...
 
virtual bool composeType (base::DataSourceBase::shared_ptr dssource, base::DataSourceBase::shared_ptr dsresult) const
 Compose a type (target) from a DataSourceBase (source) containing its members. More...
 
boost::shared_ptr< PrimitiveTypeInfo< T, use_ostream > > getSharedPtr ()
 
TypeInfogetTypeInfoObject () const
 Returns the TypeInfo object of this type, or null if none exists yet. More...
 
virtual const std::string & getTypeName () const
 Return the type name for which this generator generates type info features. More...
 
virtual std::ostream & write (std::ostream &os, base::DataSourceBase::shared_ptr in) const
 Output this datasource as a human readable string. More...
 
virtual std::istream & read (std::istream &os, base::DataSourceBase::shared_ptr out) const
 Read a new value for this datasource from a human readable string. More...
 
virtual bool isStreamable () const
 Returns true if this type is directly streamable using read()/write() or toString()/fromString(). More...
 
virtual bool decomposeType (base::DataSourceBase::shared_ptr source, PropertyBag &targetbag) const
 
base::AttributeBasebuildConstant (std::string name, base::DataSourceBase::shared_ptr dsb) const
 Build a non modifyable instance of this type. More...
 
base::AttributeBasebuildVariable (std::string name) const
 Build a non modifyable instance of this type. More...
 
base::AttributeBasebuildAttribute (std::string name, base::DataSourceBase::shared_ptr in) const
 Build an Attribute of this type. More...
 
base::AttributeBasebuildAlias (std::string name, base::DataSourceBase::shared_ptr in) const
 build an alias with b as the value. More...
 
base::DataSourceBase::shared_ptr buildActionAlias (base::ActionInterface *action, base::DataSourceBase::shared_ptr in) const
 Returns a DataSource that first executes an action and returns the result of another data source. More...
 
virtual base::PropertyBasebuildProperty (const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const
 Build a Property of this type. More...
 
virtual base::DataSourceBase::shared_ptr buildValue () const
 Build a internal::ValueDataSource of this type. More...
 
virtual base::DataSourceBase::shared_ptr buildReference (void *ptr) const
 Build a internal::ReferenceDataSource of this type, pointing to the given pointer. More...
 
virtual base::DataSourceBase::shared_ptr convertType (base::DataSourceBase::shared_ptr source) const
 Specialize this function to return an alternate type which represents this one in a compatible way. More...
 
Type building/factory functions

Used to create objects that hold data of a certain type.

virtual base::AttributeBasebuildConstant (std::string name, base::DataSourceBase::shared_ptr, int sizehint) const
 Build a non modifyable instance of this type. More...
 
virtual base::AttributeBasebuildVariable (std::string name, int sizehint) const
 Build a modifyable instance of this type. More...
 
Conversion to/from text

Used to convert data to human readable text and vice versa.

virtual std::string toString (base::DataSourceBase::shared_ptr in) const
 Usability function which converts data to a string. More...
 
virtual bool fromString (const std::string &value, base::DataSourceBase::shared_ptr out) const
 Usability function which converts a string to data. More...
 
Inspecting data structures.

Used to write a complex type to an external representation, like XML.

virtual bool resize (base::DataSourceBase::shared_ptr arg, int size) const
 Tries to resize a data source in case it's a resizable sequence. More...
 
virtual bool getMember (internal::Reference *ref, base::DataSourceBase::shared_ptr item, const std::string &name) const
 Stores a reference to a member of a struct identified by its name. More...
 

Protected Attributes

const std::string tname
 
boost::shared_ptr< PrimitiveTypeInfo< T, use_ostream > > mshared
 

Detailed Description

template<typename T, bool has_ostream = false>
class RTT::types::BoostArrayTypeInfo< T, has_ostream >

Template for data types that are of type boost::array<U,int>.

You can not use this type as a port data type. Normally, using this class is not required since RTT converts all boost::array instances to types::carray, which is represented by the CArrayTypeInfo class. Be aware that this type info object only represents the boost::array of one size, ie, this scales badly ! A CArrayTypeInfo can represent a fixed size array of any size.

Parameters
TA boost::array<U,N> wrapper, where U is a data type and N the array size.

Definition at line 68 of file BoostArrayTypeInfo.hpp.

Member Typedef Documentation

typedef T RTT::types::PrimitiveTypeInfo< T, use_ostream >::DataType
inherited

The given T parameter is the type of the DataSources.

Definition at line 44 of file PrimitiveTypeInfo.hpp.

Constructor & Destructor Documentation

template<typename T , bool has_ostream = false>
RTT::types::BoostArrayTypeInfo< T, has_ostream >::BoostArrayTypeInfo ( std::string  name)
inline

Definition at line 73 of file BoostArrayTypeInfo.hpp.

Member Function Documentation

template<class T>
base::DataSourceBase::shared_ptr RTT::types::TemplateValueFactory< T >::buildActionAlias ( base::ActionInterface action,
base::DataSourceBase::shared_ptr  source 
) const
inlinevirtualinherited

Returns a DataSource that first executes an action and returns the result of another data source.

If source is an AssignableDataSource, an AssignableDataSource is returned of the same type, otherwise, a plain DataSource is returned.

Implements RTT::types::ValueFactory.

Definition at line 62 of file TemplateValueFactory.hpp.

template<class T>
base::AttributeBase* RTT::types::TemplateValueFactory< T >::buildAlias ( std::string  name,
base::DataSourceBase::shared_ptr  b 
) const
inlinevirtualinherited

build an alias with b as the value.

If b is of the wrong type, 0 will be returned..

Implements RTT::types::ValueFactory.

Definition at line 54 of file TemplateValueFactory.hpp.

template<class T>
base::AttributeBase* RTT::types::TemplateValueFactory< T >::buildAttribute ( std::string  name,
base::DataSourceBase::shared_ptr  source 
) const
inlinevirtualinherited

Build an Attribute of this type.

Implements RTT::types::ValueFactory.

Definition at line 40 of file TemplateValueFactory.hpp.

template<class T>
base::AttributeBase* RTT::types::TemplateValueFactory< T >::buildConstant ( std::string  name,
base::DataSourceBase::shared_ptr   
) const
inlinevirtualinherited

Build a non modifyable instance of this type.

Parameters
sizehintFor variable size instances, use it to hint the size of the instance.

Implements RTT::types::ValueFactory.

Definition at line 20 of file TemplateValueFactory.hpp.

AttributeBase * RTT::ValueFactory::buildConstant ( std::string  name,
base::DataSourceBase::shared_ptr  dsb,
int  sizehint 
) const
virtualinherited

Build a non modifyable instance of this type.

Parameters
sizehintFor variable size instances, use it to hint the size of the instance.

Definition at line 14 of file ValueFactory.cpp.

template<class T>
virtual base::PropertyBase* RTT::types::TemplateValueFactory< T >::buildProperty ( const std::string &  name,
const std::string &  desc,
base::DataSourceBase::shared_ptr  source = 0 
) const
inlinevirtualinherited

Build a Property of this type.

Implements RTT::types::ValueFactory.

Definition at line 74 of file TemplateValueFactory.hpp.

template<class T>
virtual base::DataSourceBase::shared_ptr RTT::types::TemplateValueFactory< T >::buildReference ( void *  ptr) const
inlinevirtualinherited

Build a internal::ReferenceDataSource of this type, pointing to the given pointer.

Implements RTT::types::ValueFactory.

Definition at line 90 of file TemplateValueFactory.hpp.

template<class T>
virtual base::DataSourceBase::shared_ptr RTT::types::TemplateValueFactory< T >::buildValue ( ) const
inlinevirtualinherited

Build a internal::ValueDataSource of this type.

Implements RTT::types::ValueFactory.

Definition at line 87 of file TemplateValueFactory.hpp.

template<class T>
base::AttributeBase* RTT::types::TemplateValueFactory< T >::buildVariable ( std::string  name) const
inlinevirtualinherited

Build a non modifyable instance of this type.

Parameters
sizehintFor variable size instances, use it to hint the size of the instance.

Implements RTT::types::ValueFactory.

Definition at line 33 of file TemplateValueFactory.hpp.

AttributeBase * RTT::ValueFactory::buildVariable ( std::string  name,
int  sizehint 
) const
virtualinherited
template<typename T , bool has_ostream = false>
virtual bool RTT::types::BoostArrayTypeInfo< T, has_ostream >::composeType ( base::DataSourceBase::shared_ptr  source,
base::DataSourceBase::shared_ptr  target 
) const
inlinevirtual

Compose a type (target) from a DataSourceBase (source) containing its members.

The default behavior tries to assign source to target. If that fails, it tries to decompose target into its members and update the members of target with the contents of source.

The default implementation in TemplateTypeInfo works for most types, but can be overridden in case there are multiple versions/possibilities to make a target from a source. For example, in order to support legacy formats or in order to do the inverse of decomposeType().

Parameters
sourceA data source of the same type as target OR a PropertyBag that contains the parts of target to be refreshed.
targetA data source of the same type as this TypeInfo object which contains the data to be updated from source.
Returns
true if source could be updated, false otherwise.
See also
types::propertyDecomposition and types::typeDecomposition for the inverse function, decomposing a type into datasources and hierarchical properties.
decomposeType to do the inverse operation.

Implements RTT::types::CompositionFactory.

Definition at line 154 of file BoostArrayTypeInfo.hpp.

References RTT::types::composePropertyBag(), RTT::Error, RTT::PropertyBag::getType(), RTT::base::DataSourceBase::ref(), RTT::refreshProperties(), RTT::internal::DataSource< T >::rvalue(), RTT::internal::AssignableDataSource< T >::set(), RTT::PropertyBag::size(), RTT::types::typeDecomposition(), and RTT::types::Types().

base::DataSourceBase::shared_ptr CompositionFactory::convertType ( base::DataSourceBase::shared_ptr  source) const
virtualinherited

Specialize this function to return an alternate type which represents this one in a compatible way.

For example, a short converts to an long or an enum to an int or a string.

Returns
null if this type is not convertible to anything else.
Deprecated:
by decomposeType. We want to rename convertType to decomposeType. This function is left here for transitional purposes.

Definition at line 6 of file CompositionFactory.cpp.

Referenced by RTT::types::CompositionFactory::decomposeType().

virtual bool RTT::types::PrimitiveTypeInfo< T, use_ostream >::decomposeType ( base::DataSourceBase::shared_ptr  source,
PropertyBag targetbag 
) const
inlinevirtualinherited

Definition at line 123 of file PrimitiveTypeInfo.hpp.

template<typename T , bool has_ostream = false>
virtual base::DataSourceBase::shared_ptr RTT::types::BoostArrayTypeInfo< T, has_ostream >::decomposeType ( base::DataSourceBase::shared_ptr  source) const
inlinevirtual

Use getMember() for decomposition...

Reimplemented from RTT::types::CompositionFactory.

Definition at line 149 of file BoostArrayTypeInfo.hpp.

bool StreamFactory::fromString ( const std::string &  value,
base::DataSourceBase::shared_ptr  out 
) const
virtualinherited

Usability function which converts a string to data.

Definition at line 23 of file StreamFactory.cpp.

virtual bool RTT::types::MemberFactory::getMember ( internal::Reference ref,
base::DataSourceBase::shared_ptr  item,
const std::string &  name 
) const
virtualinherited

Stores a reference to a member of a struct identified by its name.

This method does not allocate memory when item is assignable..

Parameters
refThe reference object in which to store the reference.
itemThe item of which to return a reference to a member. It must be assignable, otherwise, a reference to a copy of item will be returned. This copy will allocate memory.
nameThe name of a member within item.
Returns
false if no such member exists, true if ref got filled in otherwise.

Reimplemented in RTT::types::StructTypeInfo< T, has_ostream >.

template<typename T , bool has_ostream = false>
virtual base::DataSourceBase::shared_ptr RTT::types::BoostArrayTypeInfo< T, has_ostream >::getMember ( base::DataSourceBase::shared_ptr  item,
const std::string &  name 
) const
inlinevirtual

Returns a member of a given data source struct identified by its name.

Parameters
itemThe item of which to return a reference to a member
nameThe name of a member within item. Is a name of a member in case of a struct or an index number in case of a sequence.
Returns
null if no such member exists, an assignable datasource referencing that member otherwise.

Reimplemented from RTT::types::MemberFactory.

Definition at line 99 of file BoostArrayTypeInfo.hpp.

References RTT::Error, and RTT::internal::AssignableDataSource< T >::set().

template<typename T , bool has_ostream = false>
virtual base::DataSourceBase::shared_ptr RTT::types::BoostArrayTypeInfo< T, has_ostream >::getMember ( base::DataSourceBase::shared_ptr  item,
base::DataSourceBase::shared_ptr  id 
) const
inlinevirtual

Returns a member of a given data source identified by a data source id.

This will be an int (for indexing) or a string (for the member name).

Warning
Currently this only works for a SequenceTypeInfo-like object. We don't implement this for StructTypeInfo-like objects, since that would be a very expensive implementation (memory wise).
Parameters
itemThe item of which to return a member
idOr a string data source containing the name of a member if item is a struct, Or an unsigned int data source containing the index of an element if item is a sequence

Reimplemented from RTT::types::MemberFactory.

Definition at line 121 of file BoostArrayTypeInfo.hpp.

References RTT::Error, RTT::internal::DataSource< T >::get(), RTT::internal::DataSource< T >::narrow(), and RTT::internal::AssignableDataSource< T >::set().

template<typename T , bool has_ostream = false>
virtual std::vector<std::string> RTT::types::BoostArrayTypeInfo< T, has_ostream >::getMemberNames ( ) const
inlinevirtual

Returns the list of struct member names of this type.

In case this type is not a struct, returns an empty list.

Reimplemented from RTT::types::MemberFactory.

Definition at line 91 of file BoostArrayTypeInfo.hpp.

boost::shared_ptr<PrimitiveTypeInfo<T, use_ostream> > RTT::types::PrimitiveTypeInfo< T, use_ostream >::getSharedPtr ( )
inlineinherited
TypeInfo* RTT::types::PrimitiveTypeInfo< T, use_ostream >::getTypeInfoObject ( ) const
inlinevirtualinherited

Returns the TypeInfo object of this type, or null if none exists yet.

Returns
All generators should return here TypeInfoRepository::Instance()->getTypeInfo<T>();

Implements RTT::types::TypeInfoGenerator.

Definition at line 84 of file PrimitiveTypeInfo.hpp.

virtual const std::string& RTT::types::PrimitiveTypeInfo< T, use_ostream >::getTypeName ( ) const
inlinevirtualinherited

Return the type name for which this generator generates type info features.

This name will be aliased by the TypeInfo object.

Implements RTT::types::TypeInfoGenerator.

Definition at line 88 of file PrimitiveTypeInfo.hpp.

Referenced by RTT::types::CArrayTypeInfo< T, has_ostream >::getMember().

template<typename T , bool has_ostream = false>
bool RTT::types::BoostArrayTypeInfo< T, has_ostream >::installTypeInfoObject ( TypeInfo ti)
inlinevirtual

Installs the type info object in the global data source type info handler and adds any additional features to the type info object.

This method will be called by the TypeInfoRepository, in order to register this type's factories into the TypeInfo object.

Parameters
tiA valid TypeInfo object into which new features may be installed
Returns
true if this object may be deleted, false if not.
Postcondition
When true is returned, this instance is still valid and the caller (TypeInfoRepository) will delete it. When false is returned, the validity is undefined and the instance will not be used anymore by the caller.

Implements RTT::types::TypeInfoGenerator.

Definition at line 78 of file BoostArrayTypeInfo.hpp.

References RTT::types::PrimitiveTypeInfo< T, has_ostream >::getSharedPtr(), RTT::types::PrimitiveTypeInfo< T, use_ostream >::installTypeInfoObject(), RTT::types::TypeInfo::setCompositionFactory(), and RTT::types::TypeInfo::setMemberFactory().

virtual bool RTT::types::PrimitiveTypeInfo< T, use_ostream >::isStreamable ( ) const
inlinevirtualinherited

Returns true if this type is directly streamable using read()/write() or toString()/fromString().

Implements RTT::types::StreamFactory.

Definition at line 107 of file PrimitiveTypeInfo.hpp.

virtual std::istream& RTT::types::PrimitiveTypeInfo< T, use_ostream >::read ( std::istream &  os,
base::DataSourceBase::shared_ptr  out 
) const
inlinevirtualinherited

Read a new value for this datasource from a human readable string.

The default does nothing.

Implements RTT::types::StreamFactory.

Definition at line 98 of file PrimitiveTypeInfo.hpp.

bool MemberFactory::resize ( base::DataSourceBase::shared_ptr  arg,
int  size 
) const
virtualinherited
string StreamFactory::toString ( base::DataSourceBase::shared_ptr  in) const
virtualinherited

Usability function which converts data to a string.

Definition at line 12 of file StreamFactory.cpp.

virtual std::ostream& RTT::types::PrimitiveTypeInfo< T, use_ostream >::write ( std::ostream &  os,
base::DataSourceBase::shared_ptr  in 
) const
inlinevirtualinherited

Output this datasource as a human readable string.

The default just writes the type name in parentheses to os.

Implements RTT::types::StreamFactory.

Definition at line 90 of file PrimitiveTypeInfo.hpp.

Member Data Documentation

boost::shared_ptr<PrimitiveTypeInfo<T, use_ostream> > RTT::types::PrimitiveTypeInfo< T, use_ostream >::mshared
protectedinherited

Definition at line 39 of file PrimitiveTypeInfo.hpp.

const std::string RTT::types::PrimitiveTypeInfo< T, use_ostream >::tname
protectedinherited

Definition at line 38 of file PrimitiveTypeInfo.hpp.


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