Module: OroGen::TypekitMarshallers::ROS::OpaqueTypeExtension

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



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/orogen/marshallers/ros.rb', line 535

def from_ros(typekit, buffer, indent)
    needs_copy  = typekit.opaque_specification(self).needs_copy?
    target_type = typekit.intermediate_type_for(self)
    if needs_copy
        buffer <<
            "#{indent}#{target_type.cxx_name} temp;\n" <<
            "#{indent}#{target_type.call_from_ros("temp", "ros")};\n"
            "#{indent}orogen_typekits::fromIntermediate(value, temp);\n"
    else
        buffer <<
            "#{indent}std::auto_ptr< #{target_type.cxx_name} > temp(new #{target_type.cxx_name});\n" <<
            "#{indent}#{target_type.call_from_ros("*temp", "ros")};\n"
            "#{indent}if (orogen_typekits::fromIntermediate(value, temp.get())) temp.release();\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



515
516
517
518
519
520
521
522
523
524
525
526
527
528
# File 'lib/orogen/marshallers/ros.rb', line 515

def to_ros(typekit, buffer, indent)
    needs_copy  = typekit.opaque_specification(self).needs_copy?
    target_type = typekit.intermediate_type_for(self)
    if needs_copy
        buffer <<
            "#{indent}#{target_type.cxx_name} temp;\n" <<
            "#{indent}orogen_typekits::toIntermediate(temp, value);\n" <<
            "#{indent}#{target_type.call_to_ros("ros", "temp")};\n"
    else
        buffer <<
            "#{indent}#{target_type.arg_type} temp = orogen_typekits::toIntermediate(value);\n" <<
            "#{indent}#{target_type.call_to_ros("ros", "temp")};\n"
    end
end