Orocos Real-Time Toolkit  2.6.0
Public Member Functions
RTT::types::CompositionFactory Class Reference

A factory for composing/decomposing and converting types to a form suitable for persistent storage, such as an XML file. More...

#include <rtt/types/CompositionFactory.hpp>

Inheritance diagram for RTT::types::CompositionFactory:
RTT::types::BoostArrayTypeInfo< T, has_ostream > RTT::types::CArrayTypeInfo< T, has_ostream > RTT::types::PrimitiveSequenceTypeInfo< T, has_ostream >

List of all members.

Public Member Functions

virtual bool composeType (base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const =0
 Compose a type (target) from a DataSourceBase (source) containing its members.
virtual
base::DataSourceBase::shared_ptr 
decomposeType (base::DataSourceBase::shared_ptr source) const
 Specialize this function to return an alternate type which represents this one in a compatible way.
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.

Detailed Description

A factory for composing/decomposing and converting types to a form suitable for persistent storage, such as an XML file.

Definition at line 12 of file CompositionFactory.hpp.


Member Function Documentation

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.

Implemented in RTT::types::CArrayTypeInfo< T, has_ostream >, RTT::types::BoostArrayTypeInfo< T, has_ostream >, RTT::types::EnumTypeInfo< T >, RTT::types::StdStringTypeInfo, RTT::types::RTStringTypeInfo, RTT::types::StdVectorTypeInfo, RTT::types::PrimitiveSequenceTypeInfo< T, has_ostream >, RTT::types::SequenceTypeInfo< T, has_ostream >, RTT::types::SequenceTypeInfo< rt_string, true >, RTT::types::SequenceTypeInfo< std::string, true >, RTT::types::SequenceTypeInfo< std::vector< double >, true >, and RTT::types::SequenceTypeInfo< std::vector< T >, has_ostream >.

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.

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. If your return a datasource containing a property bag, then this function should do the inverse of composeType: the returned property bag contains all parts of the current type (source) which can be modified and merged back into this type with composeType. Mathematically: composeType( decomposeType( A ), B); assert( A == B );

Returns:
null in order to indicate that decomposition through getMember() may be tried. You may return source itself in order to prevent any further decomposition of your type (using getMember(), which is used as fall-back by the rest of the software. For example, to avoid that a string is decomposed into a sequence of chars, or to avoid that a primitive type like 'int' is further queried.

Reimplemented in RTT::types::CArrayTypeInfo< T, has_ostream >, RTT::types::BoostArrayTypeInfo< T, has_ostream >, RTT::types::EnumTypeInfo< T >, RTT::types::StdStringTypeInfo, RTT::types::RTStringTypeInfo, RTT::types::StdTypeInfo< T >, RTT::types::PrimitiveSequenceTypeInfo< T, has_ostream >, RTT::types::SequenceTypeInfo< T, has_ostream >, RTT::types::SequenceTypeInfo< rt_string, true >, RTT::types::SequenceTypeInfo< std::string, true >, RTT::types::SequenceTypeInfo< std::vector< double >, true >, and RTT::types::SequenceTypeInfo< std::vector< T >, has_ostream >.

Definition at line 11 of file CompositionFactory.cpp.


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