RTI Routing Service Version 7.7.0
ProcessorPluginForwarder.hpp
1/*
2 * (c) Copyright, Real-Time Innovations, 2017.
3 * All rights reserved.
4 *
5 * No duplications, whole or partial, manual or electronic, may be made
6 * without express written permission. Any such copies, or
7 * revisions thereof, must display this notice unaltered.
8 * This code contains trade secrets of Real-Time Innovations, Inc.
9 */
10
11#ifndef RTI_ROUTING_PROCESSOR_PLUGIN_DETAIL_PROCESSOR_PLUGIN_FORWARDER_HPP_
12#define RTI_ROUTING_PROCESSOR_PLUGIN_DETAIL_PROCESSOR_PLUGIN_FORWARDER_HPP_
13
14#include <rti/core/Exception.hpp>
15
16#include <rti/routing/processor/detail/ProcessorForwarder.hpp>
17#include <rti/routing/detail/ForwarderUtils.hpp>
18
19namespace rti { namespace routing { namespace processor { namespace detail {
20
21
22class ProcessorPluginForwarder {
23public:
24
25 static RTI_RoutingServiceProcessorPlugin * create_plugin(
26 ProcessorPlugin *plugin)
27 {
28 RTI_RoutingServiceProcessorPlugin *native_plugin = NULL;
29 RTIOsapiHeap_allocateStructure(
30 &native_plugin,
31 struct RTI_RoutingServiceProcessorPlugin);
32 rti::core::check_create_entity(
33 native_plugin,
34 "RTI_RoutingServiceProcessorPlugin");
35 RTI_RoutingServiceProcessorPlugin_initialize(native_plugin);
36
37 // Set adapter version
38 rti::config::LibraryVersion version = plugin->get_version();
39 native_plugin->plugin_version.major = version.major_version();
40 native_plugin->plugin_version.minor = version.minor_version();
41 native_plugin->plugin_version.release = version.release_version();
42
43 // Initialize native implementation
44 native_plugin->processor_plugin_data =
45 static_cast<void *>(plugin);
46 native_plugin->plugin_delete =
47 ProcessorPluginForwarder::delete_plugin;
48 native_plugin->create_processor =
49 ProcessorPluginForwarder::forward_create_processor;
50 native_plugin->delete_processor =
51 ProcessorPluginForwarder::forward_delete_processor;
52
53 return native_plugin;
54 }
55
56 static void delete_plugin(
57 RTI_RoutingServiceProcessorPlugin *native_plugin,
58 RTI_RoutingServiceEnvironment *)
59 {
60 ProcessorPlugin *plugin = static_cast<ProcessorPlugin*>(
61 native_plugin->processor_plugin_data);
62 // Plug-in is destructor not allowed to throw
63 delete plugin;
64 RTIOsapiHeap_freeStructure(native_plugin);
65 }
66
67
68 static RTI_RoutingServiceProcessor * forward_create_processor(
69 void *native_plugin_data,
70 RTI_RoutingServiceRoute *native_route,
71 const struct RTI_RoutingServiceProperties *native_properties,
72 RTI_RoutingServiceEnvironment *environment)
73 {
74 return ProcessorForwarder::create_native(
75 static_cast<ProcessorPlugin *>(native_plugin_data),
76 native_route,
77 native_properties,
78 environment);
79
80 }
81
82 static void forward_delete_processor(
83 void *native_plugin_data,
84 struct RTI_RoutingServiceProcessor *native_processor,
85 RTI_RoutingServiceRoute *,
86 RTI_RoutingServiceEnvironment *environment)
87 {
88
89 ProcessorForwarder::delete_native(
90 static_cast<ProcessorPlugin *>(native_plugin_data),
91 native_processor,
92 environment);
93 }
94
95};
96
97}}}}
98
99#endif // RTI_ROUTING_PROCESSOR_PLUGIN_DETAIL_PROCESSOR_PLUGIN_FORWARDER_HPP_