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