Module: OroGen::TypekitMarshallers::ROS::ContainerTypeExtension

Defined in:
lib/orogen/marshallers/ros.rb

Instance Method Summary collapse

Instance Method Details

#from_ros(typekit, buffer, indent) ⇒ Object

Convert a C++ value into the corresponding ROS value The C++ value is called 'value' and is a ref to the C++ type. The ROS value is called 'ros' and is a const-ref.

The method must return the string that will be used for convertion



605
606
607
608
609
610
611
612
613
614
# File 'lib/orogen/marshallers/ros.rb', line 605

def from_ros(typekit, buffer, indent)
    if deference.kind_of?(Typelib::NumericType)
        buffer << "#{indent}value = ros;"
    else
        buffer <<
            "#{indent}value.resize(ros.size());\n" <<
            "#{indent}for (size_t idx = 0; idx < ros.size(); ++idx)\n" <<
            "#{indent}#{deference.call_from_ros("value[idx]", "ros[idx]")};\n"
    end
end

#to_ros(typekit, buffer, indent) ⇒ Object

Convert a C++ value into the corresponding ROS value The C++ value is called 'value' and is a const-ref to the C++ type. The ROS value is called 'ros' and is a ref.

The method must return the string that will be used for convertion



589
590
591
592
593
594
595
596
597
598
# File 'lib/orogen/marshallers/ros.rb', line 589

def to_ros(typekit, buffer, indent)
    if deference.kind_of?(Typelib::NumericType)
        buffer << "#{indent}ros = value;"
    else
        buffer <<
            "#{indent}ros.resize(value.size());\n" <<
            "#{indent}for (size_t idx = 0; idx < value.size(); ++idx)\n" <<
            "#{indent}#{deference.call_to_ros("ros[idx]", "value[idx]")};\n"
    end
end