Orocos Real-Time Toolkit  2.9.0
Public Member Functions | List of all members
RTT::types::CompositionFactory Class Referenceabstract

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 > RTT::types::TemplateCompositionFactory< T > RTT::types::TemplateCompositionFactory< bool > RTT::types::TemplateCompositionFactory< rt_string > RTT::types::TemplateCompositionFactory< std::string > RTT::types::TemplateCompositionFactory< std::vector< double > > RTT::types::TemplateCompositionFactory< std::vector< T > >

Public Member Functions

virtual ~CompositionFactory ()
 
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. More...
 
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. 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...
 

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.

Constructor & Destructor Documentation

virtual RTT::types::CompositionFactory::~CompositionFactory ( )
inlinevirtual

Definition at line 15 of file CompositionFactory.hpp.

Member Function Documentation

virtual bool RTT::types::CompositionFactory::composeType ( base::DataSourceBase::shared_ptr  source,
base::DataSourceBase::shared_ptr  target 
) const
pure virtual

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::StdTypeInfo< T >, RTT::types::StdTypeInfo< bool >, RTT::types::StdVectorTemplateTypeInfo< T, has_ostream >, 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 >, RTT::types::SequenceTypeInfo< std::vector< T >, has_ostream >, RTT::types::TemplateCompositionFactory< T >, RTT::types::TemplateCompositionFactory< rt_string >, RTT::types::TemplateCompositionFactory< std::string >, RTT::types::TemplateCompositionFactory< std::vector< T > >, RTT::types::TemplateCompositionFactory< std::vector< double > >, and RTT::types::TemplateCompositionFactory< bool >.

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

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 decomposeType().

base::DataSourceBase::shared_ptr CompositionFactory::decomposeType ( base::DataSourceBase::shared_ptr  source) const
virtual

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::StdTypeInfo< bool >, 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 >, RTT::types::SequenceTypeInfo< std::vector< T >, has_ostream >, RTT::types::TemplateCompositionFactory< T >, RTT::types::TemplateCompositionFactory< rt_string >, RTT::types::TemplateCompositionFactory< std::string >, RTT::types::TemplateCompositionFactory< std::vector< T > >, RTT::types::TemplateCompositionFactory< std::vector< double > >, and RTT::types::TemplateCompositionFactory< bool >.

Definition at line 11 of file CompositionFactory.cpp.

References convertType().


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