00001
00002
00003 #include <<%= typekit.name %>/Types.hpp>
00004 #include <<%= typekit.name %>/type_info/BoostSerialization.hpp>
00005 #include <rtt/types/StructTypeInfo.hpp>
00006 #include <rtt/types/TypeInfoRepository.hpp>
00007 #include <<%= typekit.name %>/OpaqueConvertions.hpp>
00008
00009 namespace orogen_typekits {
00010 struct <%= type.method_name(true) %>TypeInfo :
00011 public RTT::types::TemplateTypeInfo< <%= type.cxx_name %> >
00012 {
00013 typedef RTT::types::TemplateTypeInfo< <%= intermediate_type.cxx_name %> > IntermediateTypeInfo;
00014 IntermediateTypeInfo* intermediate_type_info;
00015
00016 typedef <%= type.cxx_name %> T;
00017
00018 <%= type.method_name(true) %>TypeInfo()
00019 : RTT::types::TemplateTypeInfo< <%= type.cxx_name %> >("<%= type.full_name %>")
00020 {
00021 RTT::types::TypeInfoRepository::shared_ptr ti = RTT::types::TypeInfoRepository::Instance();
00022 intermediate_type_info = dynamic_cast< IntermediateTypeInfo* >(ti->type("<%= intermediate_type.name %>"));
00023 }
00024
00025 virtual bool composeTypeImpl(const RTT::PropertyBag& source, RTT::internal::AssignableDataSource<T>::reference_t value) const
00026 {
00027 <% if needs_copy %>
00028 <%= intermediate_type.cxx_name %> intermediate;
00029 if (!intermediate_type_info->composeTypeImpl(source, intermediate))
00030 return false;
00031 <% else %>
00032 std::auto_ptr< <%= intermediate_type.cxx_name %> > intermediate(new <%= intermediate_type.cxx_name %>);
00033 if (!intermediate_type_info->composeTypeImpl(source, *intermediate))
00034 return false;
00035 <% end %>
00036
00037 <%= typekit.code_fromIntermediate(intermediate_type, needs_copy, " " * 8) %>
00038 return true;
00039 }
00040
00041 virtual RTT::base::DataSourceBase::shared_ptr getMember(RTT::base::DataSourceBase::shared_ptr item, const std::string& name) const {
00042 RTT::internal::AssignableDataSource<T>::shared_ptr value_source =
00043 boost::dynamic_pointer_cast< RTT::internal::AssignableDataSource<T> >( item );
00044 if ( !value_source ) {
00045 log(RTT::Error) << "TypeInfo of type "<< this->getTypeName() <<" can't handle (non-assignable) types of type "<< item->getTypeInfo() <<RTT::endlog();
00046 return RTT::base::DataSourceBase::shared_ptr();
00047 }
00048
00049 <%= type.cxx_name %> const& value = (*value_source).get();
00050 <%= typekit.code_toIntermediate(intermediate_type, needs_copy, " " * 8) %>
00051
00052 typedef RTT::internal::ValueDataSource< <%= intermediate_type.cxx_name %> > IntermediateSource;
00053 IntermediateSource::shared_ptr intermediate_ptr =
00054 new IntermediateSource(intermediate);
00055 return intermediate_type_info->getMember(intermediate_ptr, name);
00056 }
00057
00058 virtual RTT::base::DataSourceBase::shared_ptr getMember(RTT::base::DataSourceBase::shared_ptr item,
00059 RTT::base::DataSourceBase::shared_ptr id) const {
00060
00061 RTT::internal::AssignableDataSource<T>::shared_ptr value_source =
00062 boost::dynamic_pointer_cast< RTT::internal::AssignableDataSource<T> >( item );
00063 if ( !value_source ) {
00064 log(RTT::Error) << "TypeInfo of type "<< this->getTypeName() <<" can't handle (non-assignable) types of type "<< item->getTypeInfo() <<RTT::endlog();
00065 return RTT::base::DataSourceBase::shared_ptr();
00066 }
00067
00068 <%= type.cxx_name %> const& value = (*value_source).get();
00069 <%= typekit.code_toIntermediate(intermediate_type, needs_copy, " " * 8) %>
00070 typedef RTT::internal::ValueDataSource< <%= intermediate_type.cxx_name %> > IntermediateSource;
00071 IntermediateSource::shared_ptr intermediate_ptr =
00072 new IntermediateSource(intermediate);
00073 return intermediate_type_info->getMember(intermediate_ptr, id);
00074 }
00075 };
00076
00077 RTT::types::TypeInfo* <%= type.method_name(true) %>_TypeInfo()
00078 { return new <%= type.method_name(true) %>TypeInfo(); }
00079 }
00080
00081 <%= Generation.render_template('typekit', 'TemplateInstanciation.cpp', binding) %>
00082
00083