Class: OroGen::TypekitMarshallers::MQueue::Plugin

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typekit) ⇒ Plugin

Returns a new instance of Plugin



6
7
8
9
10
11
12
13
14
15
# File 'lib/orogen/marshallers/mqueue.rb', line 6

def initialize(typekit)
    @typekit = typekit
    Typelib::Type          .extend(TypekitMarshallers::MQueue::Type)
    Typelib::NumericType   .extend(TypekitMarshallers::MQueue::NumericType)
    Typelib::ContainerType .extend(TypekitMarshallers::MQueue::ContainerType)
    Typelib::EnumType      .extend(TypekitMarshallers::MQueue::EnumType)
    Typelib::CompoundType  .extend(TypekitMarshallers::MQueue::CompoundType)
    Typelib::ArrayType     .extend(TypekitMarshallers::MQueue::ArrayType)
    Typelib::OpaqueType    .extend(TypekitMarshallers::MQueue::OpaqueType)
end

Instance Attribute Details

#typekitObject (readonly)

Returns the value of attribute typekit



5
6
7
# File 'lib/orogen/marshallers/mqueue.rb', line 5

def typekit
  @typekit
end

Class Method Details

.nameObject



17
# File 'lib/orogen/marshallers/mqueue.rb', line 17

def self.name; "mqueue" end

.plugin_name(typekit_name) ⇒ Object



48
49
50
# File 'lib/orogen/marshallers/mqueue.rb', line 48

def self.plugin_name(typekit_name)
    "orogen_typekits::#{typekit_name}MQueueTransportPlugin"
end

Instance Method Details

#dependenciesObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/orogen/marshallers/mqueue.rb', line 20

def dependencies
    result = []
    typekit.used_typekits.each do |tk|
        next if tk.virtual?
        begin
            build_dep = Gen::RTT_CPP::BuildDependency.new(
                tk.name.upcase + "_TRANSPORT_MQUEUE",
                tk.pkg_transport_name('mqueue'))
            build_dep.in_context('mqueue', 'include')
            build_dep.in_context('mqueue', 'link')
            result << build_dep
        rescue Utilrb::PkgConfig::NotFound => e
            raise Gen::RTT_CPP::ConfigError, "the MQueue transport for the #{tk.name} typekit cannot be found. It is needed to build the MQueue transport for this project"
        end
    end
    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('mqueue', 'include')
        if needs_link
            result.last.in_context('mqueue', 'link')
        end
    end
    result
end

#generate(typesets) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/orogen/marshallers/mqueue.rb', line 52

def generate(typesets)
    headers, impl = [], []
    
    code  = Gen::RTT_CPP.render_template "typekit", "mqueue", "TransportPlugin.hpp", binding
    headers << typekit.save_automatic("transports", "mqueue",
            "TransportPlugin.hpp", code)
    code  = Gen::RTT_CPP.render_template "typekit", "mqueue", "TransportPlugin.cpp", binding
    impl << typekit.save_automatic("transports", "mqueue",
            "TransportPlugin.cpp", code)

    code_snippets = typesets.interface_types.map do |type|
        code  = Gen::RTT_CPP.render_template "typekit", "mqueue", "Type.cpp", binding
        [type, code]
    end
    impl += typekit.render_typeinfo_snippets(code_snippets, "transports", "mqueue")

    code  = Gen::RTT_CPP.render_template "typekit", "mqueue", "Registration.hpp", binding
    typekit.save_automatic("transports", "mqueue", "Registration.hpp", code)

    impl = impl.map do |path|
        typekit.cmake_relative_path(path, "transports", "mqueue")
    end
    headers = headers.map do |path|
        typekit.cmake_relative_path(path, "transports", "mqueue")
    end

    pkg_config = Gen::RTT_CPP.render_template 'typekit', "mqueue", "transport-mqueue.pc", binding
    typekit.save_automatic("transports", "mqueue", "#{typekit.name}-transport-mqueue.pc.in", pkg_config)
    code = Gen::RTT_CPP.render_template "typekit", "mqueue", "CMakeLists.txt", binding
    typekit.save_automatic("transports", "mqueue", "CMakeLists.txt", code)

    # We generate our own CMake code, no need to export anything to the
    # main typekit code
    return [], []
end

#nameObject



18
# File 'lib/orogen/marshallers/mqueue.rb', line 18

def name; "mqueue" end

#separate_cmake?Boolean

Returns:

  • (Boolean)


46
# File 'lib/orogen/marshallers/mqueue.rb', line 46

def separate_cmake?; true end