From 16c058da1a1f17209cae584f2009c3b5e3be5d4d Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Thu, 2 Sep 2010 23:42:02 +0200 Subject: [PATCH 2/2] typekit: add mqueue marshaller. Signed-off-by: Peter Soetens --- bin/typegen | 2 +- lib/orogen/marshallers/mqueue.rb | 102 ++++++++++++++++++++ lib/orogen/templates/typekit/mqueue/CMakeLists.txt | 33 +++++++ .../templates/typekit/mqueue/Registration.hpp | 16 +++ .../templates/typekit/mqueue/TransportPlugin.cpp | 33 +++++++ .../templates/typekit/mqueue/TransportPlugin.hpp | 23 +++++ lib/orogen/templates/typekit/mqueue/Type.cpp | 14 +++ .../templates/typekit/mqueue/transport-mqueue.pc | 22 ++++ lib/orogen/typekit.rb | 1 + 9 files changed, 245 insertions(+), 1 deletions(-) create mode 100644 lib/orogen/marshallers/mqueue.rb create mode 100644 lib/orogen/templates/typekit/mqueue/CMakeLists.txt create mode 100644 lib/orogen/templates/typekit/mqueue/Registration.hpp create mode 100644 lib/orogen/templates/typekit/mqueue/TransportPlugin.cpp create mode 100644 lib/orogen/templates/typekit/mqueue/TransportPlugin.hpp create mode 100644 lib/orogen/templates/typekit/mqueue/Type.cpp create mode 100644 lib/orogen/templates/typekit/mqueue/transport-mqueue.pc diff --git a/bin/typegen b/bin/typegen index 3960666..4b01182 100755 --- a/bin/typegen +++ b/bin/typegen @@ -5,7 +5,7 @@ require 'optparse' # Disable typelib plugin loading Typelib.load_type_plugins = false -DEFAULT_TRANSPORTS = %w{corba typelib} +DEFAULT_TRANSPORTS = %w{corba typelib mqueue} typekit = Orocos::Generation::Typekit.new typekit_loader = Orocos::Generation::Component.new diff --git a/lib/orogen/marshallers/mqueue.rb b/lib/orogen/marshallers/mqueue.rb new file mode 100644 index 0000000..8428aff --- /dev/null +++ b/lib/orogen/marshallers/mqueue.rb @@ -0,0 +1,102 @@ +module Orocos + module TypekitMarshallers + module MQueue + class Plugin + def initialize + 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) + end + + def self.name; "mqueue" end + def name; "mqueue" end + + def dependencies(typekit) + result = [] + typekit.used_typekits.each do |tk| + build_dep = Orocos::Generation::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 + end + result + end + + def separate_cmake?; true end + + def generate(typekit, typesets) + headers, impl = [], [] + + code = Generation.render_template "typekit", "mqueue", "TransportPlugin.hpp", binding + headers << typekit.save_automatic("transports", "mqueue", + "TransportPlugin.hpp", code) + code = Generation.render_template "typekit", "mqueue", "TransportPlugin.cpp", binding + impl << typekit.save_automatic("transports", "mqueue", + "TransportPlugin.cpp", code) + + typesets.converted_types.each do |type| + code = Generation.render_template "typekit", "mqueue", "Type.cpp", binding + impl << typekit.save_automatic("transports", "mqueue", + "#{type.name_as_word}.cpp", code) + end + typesets.opaque_types.each do |opdef| + type = opdef.type + intermediate_type = typekit.find_type(opdef.intermediate) + code = Generation.render_template "typekit", "mqueue", "Type.cpp", binding + impl << typekit.save_automatic("transports", "mqueue", + "#{type.name_as_word}.cpp", code) + end + + code = Generation.render_template "typekit", "mqueue", "Registration.hpp", binding + typekit.save_automatic("transports", "mqueue", "Registration.hpp", code) + + pkg_config = Generation.render_template 'typekit/mqueue/transport-mqueue.pc', binding + typekit.save_automatic("transports", "mqueue", "#{typekit.name}-transport-mqueue.pc.in", pkg_config) + code = Generation.render_template "typekit/mqueue/CMakeLists.txt", binding + typekit.save_automatic("transports", "mqueue", "CMakeLists.txt", code) + + #code = Generation.render_template "typekit/mqueue/Transport.hpp", binding + #typekit.save_automatic("mqueue", + # "#{typekit.name}MQueueTransport.hpp", code) + + #mqueue_hpp = Generation.render_template "typekit/mqueue/TypekitMQueue.hpp", binding + #impl << typekit.save_automatic("mqueue", "#{component.name}TypekitMQueue.hpp", mqueue_hpp) + #mqueue_impl_hpp = Generation.render_template "typekit/mqueue/TypekitMQueueImpl.hpp", binding + #impl << typekit.save_automatic("mqueue", "#{component.name}TypekitMQueueImpl.hpp", mqueue_impl_hpp) + #mqueue_cpp = Generation.render_template "typekit/mqueue/TypekitMQueue.cpp", binding + #impl << typekit.save_automatic("mqueue", "#{component.name}TypekitMQueue.cpp", mqueue_cpp) + #pkg_config = Generation.render_template 'typekit/mqueue/transport-mqueue.pc', binding + #impl << typekit.save_automatic("mqueue", "#{component.name}-transport-mqueue.pc.in", pkg_config) + + return [], [] + end + end + + module Type + end + + module NumericType + end + + module ContainerType + end + + module EnumType + end + + module CompoundType + end + + module ArrayType + end + Orocos::Generation::Typekit.register_plugin(Plugin) + + end + end +end + diff --git a/lib/orogen/templates/typekit/mqueue/CMakeLists.txt b/lib/orogen/templates/typekit/mqueue/CMakeLists.txt new file mode 100644 index 0000000..cf64d30 --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/CMakeLists.txt @@ -0,0 +1,33 @@ +# Generated from orogen/lib/orogen/templates/typekit/mqueue/CMakeLists.txt + +find_package(Orocos-RTT) + +# Set up generation of IDL files for MQueue support +IF (NOT OROCOS-RTT_MQUEUE_FOUND) + MESSAGE(FATAL_ERROR "could not find development files for Orocos/MQueue") +ENDIF(NOT OROCOS-RTT_MQUEUE_FOUND) + +set(MQueue_FILES "") + +# Generate the MQueue transport +set(libname_mqueue <%= typekit.name %>-transport-mqueue-${OROCOS_TARGET}) +add_library(${libname_mqueue} SHARED + <%= impl.join("\n ") %> + ${MQueue_FILES}) +target_link_libraries(${libname_mqueue} + <%= typekit.name %>-typekit-${OROCOS_TARGET} + ${OROCOS-RTT_MQUEUE_LIBRARIES}) + +<%= typekit_deps = typekit.plugin('mqueue').dependencies(typekit); + Generation.cmake_pkgconfig_link('mqueue', '${libname_mqueue}', typekit_deps) %> +target_link_libraries(${libname_mqueue} LINK_INTERFACE_LIBRARIES ${OROCOS-RTT_MQUEUE_LIBRARIES}) + +SET(PKG_CONFIG_FILE_MQueue ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>-transport-mqueue-${OROCOS_TARGET}.pc) +CONFIGURE_FILE(<%= typekit.name %>-transport-mqueue.pc.in ${PKG_CONFIG_FILE_MQueue} @ONLY) + +install(TARGETS ${libname_mqueue} LIBRARY DESTINATION lib/orocos/types) +install(FILES ${PKG_CONFIG_FILE_MQueue} DESTINATION lib/pkgconfig) +install(FILES + <%= headers.join("\n ") %> + DESTINATION include/orocos/<%= typekit.name %>/transports/mqueue) + diff --git a/lib/orogen/templates/typekit/mqueue/Registration.hpp b/lib/orogen/templates/typekit/mqueue/Registration.hpp new file mode 100644 index 0000000..0e1ece9 --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/Registration.hpp @@ -0,0 +1,16 @@ +/* Generated from orogen/lib/orogen/templates/typekit/mqueue/Registration.hpp */ + +#ifndef <%= typekit.name.upcase %>_MQUEUE_REGISTRATION_HPP +#define <%= typekit.name.upcase %>_MQUEUE_REGISTRATION_HPP + +#include + +namespace orogen_typekits { + <% typesets.registered_types.each do |type| %> + RTT::types::TypeMarshaller* <%= type.method_name %>_MQueueTransport(); + <% end %> +} + +#endif + + diff --git a/lib/orogen/templates/typekit/mqueue/TransportPlugin.cpp b/lib/orogen/templates/typekit/mqueue/TransportPlugin.cpp new file mode 100644 index 0000000..6a71a63 --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/TransportPlugin.cpp @@ -0,0 +1,33 @@ +/* Generated from orogen/lib/orogen/templates/typekit/mqueue/TransportPlugin.cpp */ + +// First load all RTT interfaces so that we get all "extern template" +// declarations in the TypekitImpl files +#include "transports/mqueue/Registration.hpp" +#include "transports/mqueue/TransportPlugin.hpp" +#include +#include +using namespace RTT; + +bool orogen_typekits::<%= typekit.name %>MQueueTransportPlugin::registerTransport(std::string type_name, RTT::types::TypeInfo* ti) +{ + <% first_type = true; + typesets.registered_types.each do |type| %> + <%= 'else ' unless first_type %>if ("<%= type.name %>" == type_name) + { + ti->addProtocol(ORO_MQUEUE_PROTOCOL_ID, + <%= type.method_name %>_MQueueTransport()); + return true; + } + <% first_type = false + end %> + return false; +} +std::string orogen_typekits::<%= typekit.name %>MQueueTransportPlugin::getTransportName() const +{ return "MQueue"; } +std::string orogen_typekits::<%= typekit.name %>MQueueTransportPlugin::getTypekitName() const +{ return "/orogen/<%= typekit.name %>"; } +std::string orogen_typekits::<%= typekit.name %>MQueueTransportPlugin::getName() const +{ return "/orogen/<%= typekit.name %>/MQueue"; } + +ORO_TYPEKIT_PLUGIN(orogen_typekits::<%= typekit.name %>MQueueTransportPlugin); + diff --git a/lib/orogen/templates/typekit/mqueue/TransportPlugin.hpp b/lib/orogen/templates/typekit/mqueue/TransportPlugin.hpp new file mode 100644 index 0000000..3416705 --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/TransportPlugin.hpp @@ -0,0 +1,23 @@ +/* Generated from orogen/lib/orogen/templates/typekit/mqueue/TransportPlugin.hpp */ + +#ifndef OROCOS_<%= typekit.name.upcase %>_MQUEUE_PLUGIN_HPP +#define OROCOS_<%= typekit.name.upcase %>_MQUEUE_PLUGIN_HPP + +#include + +namespace orogen_typekits { + class <%= typekit.name %>MQueueTransportPlugin + : public RTT::types::TransportPlugin + { + public: + virtual bool registerTransport(std::string type_name, RTT::types::TypeInfo* ti); + virtual std::string getTransportName() const; + virtual std::string getTypekitName() const; + virtual std::string getName() const; + }; + + extern <%= typekit.name %>MQueueTransportPlugin <%= typekit.name %>MQueueTransport; +} + +#endif + diff --git a/lib/orogen/templates/typekit/mqueue/Type.cpp b/lib/orogen/templates/typekit/mqueue/Type.cpp new file mode 100644 index 0000000..8f59dbd --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/Type.cpp @@ -0,0 +1,14 @@ +/* Generated from orogen/lib/orogen/templates/typekit/mqueue/Type.cpp */ + +#include "Types.hpp" +#include "transports/mqueue/Registration.hpp" +#include + + +namespace orogen_typekits { + RTT::types::TypeMarshaller* <%= type.method_name %>_MQueueTransport() + { + return new RTT::mqueue::MQSerializationProtocol< <%= type.cxx_name %> >(); + } +} + diff --git a/lib/orogen/templates/typekit/mqueue/transport-mqueue.pc b/lib/orogen/templates/typekit/mqueue/transport-mqueue.pc new file mode 100644 index 0000000..21f8e41 --- /dev/null +++ b/lib/orogen/templates/typekit/mqueue/transport-mqueue.pc @@ -0,0 +1,22 @@ +# Generated from orogen/lib/orogen/templates/typekit/mqueue/transport-mqueue.pc + +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib/orocos/types +includedir=${prefix}/include/orocos + +project_name=<%= typekit.name %> +<% if typekit.component %> +deffile=${prefix}/share/orogen/<%= File.basename(typekit.component.deffile) %> +<% end %> +type_registry=${prefix}/share/orogen/<%= typekit.name %>.tlb + +Name: <%= typekit.name %>MQueueTransport +Version: <%= typekit.version %> +<% unless typekit.internal_dependencies.empty? %> +Requires: <%= typekit.internal_dependencies.map { |n, v| v ? "#{n} >= #{v}" : n.to_s }.join(", ") %> +<% end %> +Description: <%= typekit.name %> types support for the Orocos type system +Libs: -L${libdir} -l@libname_mqueue@ +Cflags: -I${includedir} + diff --git a/lib/orogen/typekit.rb b/lib/orogen/typekit.rb index 2a87963..f4be04b 100644 --- a/lib/orogen/typekit.rb +++ b/lib/orogen/typekit.rb @@ -1409,3 +1409,4 @@ end require 'orogen/marshallers/typelib' require 'orogen/marshallers/corba' require 'orogen/marshallers/type_info' +require 'orogen/marshallers/mqueue' -- 1.6.3.3