#include <CompositionFactory.hpp>
Public Member Functions | |
virtual bool | composeType (base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const =0 |
virtual base::DataSourceBase::shared_ptr | convertType (base::DataSourceBase::shared_ptr source) const |
virtual base::DataSourceBase::shared_ptr | decomposeType (base::DataSourceBase::shared_ptr source) const |
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.
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().
source | A data source of the same type as target OR a PropertyBag that contains the parts of target to be refreshed. |
target | A data source of the same type as this TypeInfo object which contains the data to be updated from source. |
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::StdVectorTemplateTypeInfo< T, has_ostream >, RTT::types::StdTypeInfo< bool >, 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.
Definition at line 6 of file CompositionFactory.cpp.
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 );
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.