Class: OroGen::TypekitMarshallers::TypelibMarshaller::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/orogen/marshallers/typelib.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typekit) ⇒ Plugin


9
10
11
# File 'lib/orogen/marshallers/typelib.rb', line 9

def initialize(typekit)
    @typekit = typekit
end

Instance Attribute Details

#typekitObject (readonly)

Returns the value of attribute typekit


8
9
10
# File 'lib/orogen/marshallers/typelib.rb', line 8

def typekit
  @typekit
end

Class Method Details

.nameObject


5
# File 'lib/orogen/marshallers/typelib.rb', line 5

def self.name; "typelib" end

Instance Method Details

#dependenciesObject


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/orogen/marshallers/typelib.rb', line 13

def dependencies
    result = []
    typekit.used_libraries.each do |pkg|
        needs_link = typekit.linked_used_libraries.include?(pkg)
        result << Gen::RTT_CPP::BuildDependency.new(pkg.name.upcase, pkg.name).
            in_context('typelib', 'include')
        if needs_link
            result.last.in_context('typelib', 'link')
        end
    end
    result
end

#generate(typesets) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/orogen/marshallers/typelib.rb', line 28

def generate(typesets)
    impl    = []
    headers = []

    code_snippets = typesets.interface_types.map do |type|
        if type.contains_opaques?
            needs_copy =
                if type.opaque?
                    typekit.opaque_specification(type).needs_copy?
                else true
                end

            intermediate = typekit.intermediate_type_for(type)
            code  = Gen::RTT_CPP.render_template "typekit", "typelib", "OpaqueType.cpp", binding
        else
            code  = Gen::RTT_CPP.render_template "typekit", "typelib", "Type.cpp", binding
        end
        [type, code]
    end
    impl += typekit.render_typeinfo_snippets(code_snippets, "transports", "typelib")

    code = Gen::RTT_CPP.render_template "typekit", "typelib", "Registration.hpp", binding
    headers << typekit.save_automatic("transports", "typelib", "Registration.hpp", code)
    code = Gen::RTT_CPP.render_template "typekit", "typelib", "TransportPlugin.hpp", binding
    headers << typekit.save_automatic("transports", "typelib", "TransportPlugin.hpp", code)
    code = Gen::RTT_CPP.render_template "typekit", "typelib", "TransportPlugin.cpp", binding
    impl << typekit.save_automatic("transports", "typelib", "TransportPlugin.cpp", code)
    pkg_config = Gen::RTT_CPP.render_template "typekit", "typelib", "transport-typelib.pc", binding
    typekit.save_automatic("transports", "typelib", "#{typekit.name}-transport-typelib.pc.in", pkg_config)
    code = Gen::RTT_CPP.render_template "typekit", "typelib", "CMakeLists.txt", binding
    typekit.save_automatic("transports", "typelib", "CMakeLists.txt", code)

    return [], []
end

#nameObject


6
# File 'lib/orogen/marshallers/typelib.rb', line 6

def name; "typelib" end

#separate_cmake?Boolean


26
# File 'lib/orogen/marshallers/typelib.rb', line 26

def separate_cmake?; true end