Module: OroGen::TypekitMarshallers::Corba::EnumType

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

Instance Method Summary collapse

Instance Method Details

#from_corba(typekit, result, indent) ⇒ Object


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/orogen/marshallers/corba.rb', line 345

def from_corba(typekit, result, indent)
    seen_values = Set.new
    namespace = namespace('::')
    result << indent << "switch(corba) {\n"
    keys.each do |name, value|
        next if seen_values.include?(value)
        seen_values << value

        result << indent << "  case orogen#{namespace}Corba::#{name}:\n"
        result << indent << "    value = #{namespace}#{name};\n"
        result << indent << "    break;\n"
    end
    result << "\#{indent}  default:\n\#{indent}    RTT::log(RTT::Error) << \"orogen_typekits::fromCORBA() invalid value '\" << (int)corba << \"' for enum '\#{cxx_name}'\" << RTT::endlog();\n\#{indent}    return false;\n"
    result << indent << "}\n"
end

#to_corba(typekit, result, indent) ⇒ Object


326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/orogen/marshallers/corba.rb', line 326

def to_corba(typekit, result, indent)
    seen_values = Set.new
    namespace = namespace('::')
    result << indent << "switch(value) {\n"
    keys.each do |name, value|
        next if seen_values.include?(value)
        seen_values << value

        result << indent << "  case #{namespace}#{name}:\n"
        result << indent << "    corba = orogen#{namespace}Corba::#{name};\n"
        result << indent << "    break;\n"
    end
    result << "\#{indent}  default:\n\#{indent}    RTT::log(RTT::Error) << \"orogen_typekits::toCORBA() invalid value '\" << (int)value << \"' for enum '\#{cxx_name}'\" << RTT::endlog();\n\#{indent}    return false;\n"
    result << indent << "}\n"
end