RTI Routing Service  Version 6.0.1
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
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 
17 #include <rti/routing/processor/detail/ProcessorForwarder.hpp>
18 #include <rti/routing/detail/ForwarderUtils.hpp>
19 
20 namespace rti { namespace routing { namespace processor { namespace detail {
21 
22 
23 class ProcessorPluginForwarder {
24 public:
25 
26  static RTI_RoutingServiceProcessorPlugin * create_plugin(
27  ProcessorPlugin *plugin)
28  {
29  RTI_RoutingServiceProcessorPlugin *native_plugin = NULL;
30  RTIOsapiHeap_allocateStructure(
31  &native_plugin,
32  struct RTI_RoutingServiceProcessorPlugin);
33  rti::core::check_create_entity(
34  native_plugin,
35  "RTI_RoutingServiceProcessorPlugin");
36  RTI_RoutingServiceProcessorPlugin_initialize(native_plugin);
37 
38  // Set adapter version
39  rti::config::LibraryVersion version = plugin->get_version();
40  native_plugin->plugin_version.major = version.major_version();
41  native_plugin->plugin_version.minor = version.minor_version();
42  native_plugin->plugin_version.release = version.release_version();
43 
44  // Initialize native implementation
45  native_plugin->processor_plugin_data =
46  static_cast<void *>(plugin);
47  native_plugin->plugin_delete =
48  ProcessorPluginForwarder::delete_plugin;
49  native_plugin->create_processor =
50  ProcessorPluginForwarder::forward_create_processor;
51  native_plugin->delete_processor =
52  ProcessorPluginForwarder::forward_delete_processor;
53 
54  return native_plugin;
55  }
56 
57  static void delete_plugin(
58  RTI_RoutingServiceProcessorPlugin *native_plugin,
59  RTI_RoutingServiceEnvironment *)
60  {
61  ProcessorPlugin *plugin = static_cast<ProcessorPlugin*>(
62  native_plugin->processor_plugin_data);
63  // Plug-in is destructor not allowed to throw
64  delete plugin;
65  RTIOsapiHeap_freeStructure(native_plugin);
66  }
67 
68 
69  static RTI_RoutingServiceProcessor * forward_create_processor(
70  void *native_plugin_data,
71  RTI_RoutingServiceRoute *native_route,
72  const struct RTI_RoutingServiceProperties *native_properties,
73  RTI_RoutingServiceEnvironment *environment)
74  {
75  return ProcessorForwarder::create_native(
76  static_cast<ProcessorPlugin *>(native_plugin_data),
77  native_route,
78  native_properties,
79  environment);
80 
81  }
82 
83  static void forward_delete_processor(
84  void *native_plugin_data,
85  struct RTI_RoutingServiceProcessor *native_processor,
86  RTI_RoutingServiceRoute *,
87  RTI_RoutingServiceEnvironment *environment)
88  {
89 
90  ProcessorForwarder::delete_native(
91  static_cast<ProcessorPlugin *>(native_plugin_data),
92  native_processor,
93  environment);
94  }
95 
96 };
97 
98 }}}}
99 
100 #endif // RTI_ROUTING_PROCESSOR_PLUGIN_DETAIL_PROCESSOR_PLUGIN_FORWARDER_HPP_

RTI Routing Service Version 6.0.1 Copyright © Sun Nov 17 2019 Real-Time Innovations, Inc