module OroGen::Gen::RTT_CPP::OperationGeneration
Module that is used to add code generation functionality to Spec::Operation
Public Class Methods
new()
click to toggle source
# File lib/orogen/gen/tasks.rb, line 188 def initialize @method_name = self.name.dup method_name[0, 1] = method_name[0, 1].downcase end
Public Instance Methods
argument_signature(with_names = true, with_types = true)
click to toggle source
Returns the argument part of the C++ signature for this callable
# File lib/orogen/gen/tasks.rb, line 213 def argument_signature(with_names = true, with_types = true) arglist = arguments.map do |name, type, doc, qualified_type| # Auto-add const-ref for non-trivial types arg = if type.cxx_name == qualified_type && !(type < Typelib::NumericType) "#{type.cxx_name} const &" else qualified_type end ("#{arg if with_types} #{name if with_names}").strip end arglist.join(", ") end
register_for_generation()
click to toggle source
Called to register methods/hook code and so on on the task context
# File lib/orogen/gen/tasks.rb, line 239 def register_for_generation thread_flag = if in_caller_thread then "RTT::ClientThread" else "RTT::OwnThread" end constructor = "provides()->addOperation( _#{name})\n" + " .doc(#{Generation.multiline_string_to_cxx(doc)})" if !arguments.empty? constructor += "\n" + arguments.map { |n, _, d| " .arg(\"#{n}\", \"#{d}\")" }.join("\n") end if hidden? && !self.base_body raise InternalError, "a hidden operation with name #{name} must have a body" end body = if self.body self.body elsif has_return_value? " return #{return_type.first.cxx_name}();" else "" end task.add_base_member("operation", "_#{name}", "RTT::Operation< #{signature(false)} >"). initializer("_#{name}(\"#{name}\", &#{task.basename}Base::#{method_name}, this, #{thread_flag})"). constructor("#{constructor};") if hidden? || base_body task.add_base_method(return_type[1], method_name, argument_signature). body(base_body). doc("base implementation of the #{method_name} operation") end if !hidden? task.add_user_method(return_type[1], method_name, argument_signature). body(body). doc(doc || "Handler for the #{method_name} operation") end end
signature(with_names = true) { || ... }
click to toggle source
Returns the C++ signature for this operation. Used in code generation only.
# File lib/orogen/gen/tasks.rb, line 195 def signature(with_names = true) result = return_type[1].dup if with_names result << " " << if block_given? then yield else method_name end end result << "(" << argument_signature(with_names) << ")" end
used_types()
click to toggle source
Returns the set of types that this operation uses, as a Set of Typelib::Type classes.
# File lib/orogen/gen/tasks.rb, line 208 def used_types each_interface_type.to_a end