Go to the documentation of this file.00001
00002
00003 #include <<%= typekit.name %>/typekit/OpaqueConvertions.hpp>
00004 #include <<%= typekit.name %>/typekit/OpaqueTypes.hpp>
00005 #include <memory>
00006 #include <stdexcept>
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
00011 <% needed_typekits = Set.new
00012 types_containing_opaques.each do |t|
00013 t.direct_dependencies.each do |dep_t|
00014 if dep_t.contains_opaques?
00015 needed_typekits |= typekit.imported_typekits_for(dep_t).to_set
00016 end
00017 end
00018 end
00019 %>
00020 <% needed_typekits.sort_by(&:name).each do |tk| %>
00021 #include <<%= tk.name %>/typekit/OpaqueConvertions.hpp>
00022 <% end %>
00023
00024 <% # We first handle the definitions that declare convertions functions
00025 # (i.e. the ones for which we don't need to generate anything)
00026 type_sets.opaque_types.find_all(&:code_generator).
00027 each do |opdef|
00028 type = opdef.type
00029 target_type = typekit.intermediate_type_for(type)
00030 %>
00031 <%= opdef.code_generator.call(type, target_type) %>
00032 <% end %>
00033
00034
00035 <%
00036 # Generate the body of the const-function for from_intermediate,
00037 # if the type does not need a copy.
00038 # See the Opaques.hpp template for more information
00039 type_sets.opaque_types.find_all { |opdef| !opdef.needs_copy? }.
00040 each do |opdef|
00041 type = opdef.type
00042 target_type = typekit.intermediate_type_for(type)
00043 %>
00044 void orogen_typekits::fromIntermediate(<%= type.ref_type %> value, <%= target_type.arg_type %> _intermediate)
00045 {
00046 std::auto_ptr< <%= target_type.cxx_name %> > intermediate(new <%= target_type.cxx_name %>(_intermediate));
00047 <%= typekit.code_fromIntermediate(target_type, false, " ") %>
00048 }
00049 <%
00050 end
00051 %>
00052
00053 <%
00054 # Then create the functions that convert a type that contains
00055 # opaques (but is not opaque itself) into its corresponding _m type
00056 types_containing_opaques.each do |type|
00057 m_type = intermediate_type_for(type) %>
00058 void orogen_typekits::toIntermediate(<%= m_type.ref_type %> intermediate, <%= type.arg_type %> value<%= ", int length" if type < Typelib::ArrayType %>)
00059 {
00060 <%=
00061 result = ""
00062 type.to_intermediate(typekit, result, " ")
00063 result %>
00064 }
00065 void orogen_typekits::fromIntermediate(<%= type.ref_type %> value<%= ", int length" if type < Typelib::ArrayType %>, <%= m_type.arg_type %> intermediate)
00066 {
00067 <%=
00068 result = ""
00069 type.from_intermediate(typekit, result, " ")
00070 result %>
00071 }
00072 <% end %>
00073