Convertions.cpp
Go to the documentation of this file.
00001 /* Generated from orogen/lib/orogen/templates/typekit/ros/Convertions.cpp */
00002 
00003 #include "Convertions.hpp"
00004 #include <memory>
00005 
00006 <% if typekit.has_opaques? %>
00007 #include <<%= typekit.name %>/typekit/OpaqueConvertions.hpp>
00008 <% end %>
00009 
00010 <% typekit.used_typekits.each do |tk| %>
00011 <% next if tk.virtual? %>
00012 #include <<%= tk.name %>/transports/ros/Convertions.hpp>
00013 <% if tk.has_opaques? %>
00014 #include <<%= tk.name %>/typekit/OpaqueConvertions.hpp>
00015 <% end %>
00016 <% end %>
00017 
00018 namespace ros_convertions {
00019     template<typename ROS, typename CXX>
00020     inline void toROS(ROS& ros, CXX const& value) { ros = value; }
00021     // Cast needed for the enums
00022     template<typename ROS, typename CXX>
00023     inline void fromROS(CXX& value, ROS const& ros) { value = static_cast<CXX>(ros); }
00024     template<typename ROS, typename CXX>
00025     inline void toROS(ROS& ros, CXX const* value, int length)
00026     {
00027         ros.resize(length);
00028         for (int idx = 0; idx < length; ++idx)
00029             ros[idx] = value[idx];
00030     }
00031     template<typename ROS, typename CXX>
00032     inline void fromROS(CXX* value, ROS const& ros, int length)
00033     {
00034         for (int idx = 0; idx < length; ++idx)
00035             value[idx] = static_cast<CXX>(ros[idx]);
00036     }
00037 }
00038 
00039 <% convert_types.each do |type, ros_type|  %>
00040 void ros_convertions::toROS( <%= ros_ref_type(ros_type) %> ros, <%= type.arg_type %> value )
00041 {
00042 <%= result = ""
00043         type.to_ros(typekit, result, " " * 4)
00044         result 
00045         %>
00046 }
00047 void ros_convertions::fromROS( <%= type.ref_type %> value, <%= ros_arg_type(ros_type) %> ros )
00048 {
00049 <%= result = ""
00050         type.from_ros(typekit, result, " " * 4)
00051         result 
00052         %>
00053 }
00054 <% end %>
00055 
00056 <% convert_array_types.each do |type, ros_type| %>
00057 <%   next if type <= Typelib::NumericType  %>
00058 void ros_convertions::toROS( std::vector< <%= ros_cxx_type(ros_type) %> >& ros, <%= type.cxx_name%> const* value, int length )
00059 {
00060     ros.resize(length);
00061     for (int idx = 0; idx < length; ++idx)
00062         <%= type.call_to_ros("ros[idx]", "value[idx]") %>;
00063 }
00064 void ros_convertions::fromROS( <%= type.cxx_name %>* value, std::vector< <%= ros_cxx_type(ros_type) %> > const& ros, int length )
00065 {
00066     for (int idx = 0; idx < length; ++idx)
00067         <%= type.call_from_ros("value[idx]", "ros[idx]") %>;
00068 }
00069 <% end %>
00070 
00071 <% convert_boxed_types.each do |type, ros_type| %>
00072 void ros_convertions::toROS( <%= ros_ref_type(ros_type, false) %> ros, <%= type.arg_type %> value )
00073 { return toROS(ros.data, value); }
00074 void ros_convertions::fromROS( <%= type.ref_type %> value, <%= ros_arg_type(ros_type, false) %> ros )
00075 { return fromROS(value, ros.data); }
00076 <% end %>
00077 


orogen
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Sat Jun 8 2019 19:52:17