OpaqueConvertions.hpp
Go to the documentation of this file.
00001 /* Generated from orogen/lib/orogen/templates/typekit/OpaqueConvertions.hpp */
00002 
00003 #ifndef __OROGEN_GENERATED_<%= typekit.name %>_OPAQUE_CONVERTIONS_HH
00004 #define __OROGEN_GENERATED_<%= typekit.name %>_OPAQUE_CONVERTIONS_HH
00005 
00006 #include <boost/cstdint.hpp>
00007 #include <<%= typekit.name %>/Types.hpp>
00008 <% if typekit.has_opaques_with_templates? %>
00009 #include <<%= typekit.name %>/Opaques.hpp>
00010 <% end %>
00011 
00012 namespace orogen_typekits
00013 {
00014 <%
00015 type_sets.opaque_types.find_all { |op| !op.generate_templates? }.each do |opaque_def|
00016     from = opaque_def.type
00017     into = typekit.intermediate_type_for(from)
00018 
00019     if opaque_def.needs_copy? %>
00021     void toIntermediate(<%= into.ref_type %> intermediate, <%= from.arg_type %> real_type);
00023     void fromIntermediate(<%= from.ref_type %> real_type, <%= into.arg_type %> intermediate);
00024     <%
00025     else
00026     %>
00028     <%= into.arg_type %> toIntermediate(<%= from.arg_type %> real_type);
00031     bool fromIntermediate(<%= from.ref_type %> real_type, <%= into.cxx_name %>* intermediate);
00032     <%
00033     end
00034 end
00035 %>
00036 
00037 <%
00038 # Types that do not need copies require the intermediate to be a non-const
00039 # pointer. In case only a const-pointer is available, it is needed to create a
00040 # copy first, and then assign it to the real type (usually, a smart pointer).
00041 #
00042 # This generates the overloaded from_intermediate function that does just that.
00043 type_sets.opaque_types.find_all { |opdef| !opdef.needs_copy? }.each do |opdef|
00044     type = opdef.type
00045     intermediate_type = typekit.intermediate_type_for(type)
00046 %>
00050     void fromIntermediate(<%= type.ref_type %> value, <%= intermediate_type.arg_type %> _intermediate);
00051 <% end %>
00052 
00053 <%
00054 # This handles the types that contain opaques, but are not opaque themselves. For those,
00055 # orogen generates so-called m-types, that are a mapping from the original (opaque-containing)
00056 # type into a one where opaque fields have been converted to their intermediate counterparts
00057 type_sets.types.
00058     find_all { |t| t.contains_opaques? && !t.opaque? }.
00059     each do |type|
00060         m_type = typekit.intermediate_type_for(type)
00061         if !m_type
00062             raise RuntimeError, "no intermediate marshalling type for #{type.name}"
00063         end
00064 %>
00065     void toIntermediate(<%= m_type.ref_type %> intermediate, <%= type.arg_type %> value<%= ", int length" if type < Typelib::ArrayType %>);
00066     void fromIntermediate(<%= type.ref_type %> value<%= ", int length" if type < Typelib::ArrayType %>, <%= m_type.arg_type %> intermediate);
00067 <% end %>
00068 }
00069 
00070 #endif
00071 


orogen
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Thu Jan 2 2014 11:38:57