Class: OroGen::Gen::RTT_CPP::TaskContextGeneration::GeneratedMethod

Inherits:
GeneratedObject
  • Object
show all
Defined in:
lib/orogen/gen/tasks.rb

Overview

Represents a method definition/declaration in the generated code

This is mainly meant for plugins

See also #in_base_hook to add code to the hooks

Instance Attribute Summary collapse

Attributes inherited from GeneratedObject

#task

Instance Method Summary collapse

Methods inherited from GeneratedObject

code_snippet, #doc, #with_indent

Constructor Details

#initialize(task, return_type, name, signature) ⇒ GeneratedMethod


813
814
815
816
817
818
819
# File 'lib/orogen/gen/tasks.rb', line 813

def initialize(task, return_type, name, signature)
    super(task)

    @return_type = return_type
    @name = name
    @signature = signature
end

Instance Attribute Details

#in_baseObject

Returns the value of attribute in_base


807
808
809
# File 'lib/orogen/gen/tasks.rb', line 807

def in_base
  @in_base
end

#nameObject (readonly)

Returns the value of attribute name


810
811
812
# File 'lib/orogen/gen/tasks.rb', line 810

def name
  @name
end

#return_typeObject (readonly)

Returns the value of attribute return_type


809
810
811
# File 'lib/orogen/gen/tasks.rb', line 809

def return_type
  @return_type
end

#signatureObject (readonly)

Returns the value of attribute signature


811
812
813
# File 'lib/orogen/gen/tasks.rb', line 811

def signature
  @signature
end

Instance Method Details

#generate_declarationObject


823
824
825
826
827
828
829
830
831
832
# File 'lib/orogen/gen/tasks.rb', line 823

def generate_declaration
    decl = "virtual #{return_type} #{name}(#{signature})"
    if doc
        decl = "#{doc} */\n#{decl}"
    end
    if !body
        decl = "#{decl} = 0"
    end
    "#{decl};"
end

#generate_definitionObject


834
835
836
837
838
839
840
841
# File 'lib/orogen/gen/tasks.rb', line 834

def generate_definition
    if body
        "#{return_type} #{task.basename}#{'Base' if in_base}::#{name}(#{signature})\n" +
        "{\n" +
        generate_body +
        "\n}"
    end
end