RTI Routing Service  Version 6.0.1
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
AdapterForwarder.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_ADAPTER_DETAIL_ADAPTER_FORWARDER_HPP_
12 #define RTI_ROUTING_ADAPTER_DETAIL_ADAPTER_FORWARDER_HPP_
13 
14 #include <rti/core/Exception.hpp>
15 
16 #include <routingservice/routingservice_adapter_new.h>
17 
19 #include <rti/routing/adapter/detail/ConnectionForwarder.hpp>
20 
21 namespace rti { namespace routing { namespace adapter { namespace detail {
22 
23 
24 class AdapterForwarder {
25 public:
26  static RTI_RoutingServiceAdapterPluginExt * create_plugin(
27  AdapterPlugin *adapter_plugin)
28  {
29  RTI_RoutingServiceAdapterPluginExt *native_adapter = NULL;
30  RTIOsapiHeap_allocateStructure(
31  &native_adapter,
32  struct RTI_RoutingServiceAdapterPluginExt);
33  rti::core::check_create_entity(
34  native_adapter,
35  "RTI_RoutingServiceAdapterPluginExt");
36  RTI_RoutingServiceAdapterPluginExt_initialize(native_adapter);
37 
38  // Set adapter version
39  rti::config::LibraryVersion version = adapter_plugin->get_version();
40  native_adapter->plugin_version.major = version.major_version();
41  native_adapter->plugin_version.minor = version.minor_version();
42  native_adapter->plugin_version.release = version.release_version();
43 
44  // Initialize adapter methods
45  native_adapter->adapter_plugin_data =
46  static_cast<void *>(adapter_plugin);
47  native_adapter->plugin_delete =
48  AdapterForwarder::delete_plugin;
49  native_adapter->create_connection =
50  AdapterForwarder::create_connection;
51  native_adapter->delete_connection =
52  AdapterForwarder::delete_connection;
53 
54 
55  return native_adapter;
56  }
57 
58  static void delete_plugin(
59  RTI_RoutingServiceAdapterPluginExt *native_adapter,
60  RTI_RoutingServiceEnvironment *)
61  {
62  AdapterPlugin *adapter = static_cast<AdapterPlugin *>(
63  native_adapter->adapter_plugin_data);
64  // Plug-in is destructor not allowed to throw
65  delete adapter;
66  RTIOsapiHeap_freeStructure(native_adapter);
67  }
68 
69  static RTI_RoutingServiceConnectionExt* create_connection(
70  void *native_adapter_data,
71  const char *routing_service_name,
72  const char *routing_service_group_name,
73  const RTI_RoutingServiceStreamReaderListenerExt *native_output_stream_listener,
74  const RTI_RoutingServiceStreamReaderListenerExt *native_input_stream_listener,
75  const RTI_RoutingServiceTypeInfo **registered_types,
76  int registered_type_count,
77  const RTI_RoutingServiceProperties *native_properties,
78  RTI_RoutingServiceEnvironment *environment)
79  {
80  return ConnectionForwarder::create_native(
81  static_cast<AdapterPlugin *>(native_adapter_data),
82  routing_service_name,
83  routing_service_group_name,
84  native_output_stream_listener,
85  native_input_stream_listener,
86  registered_types,
87  registered_type_count,
88  native_properties,
89  environment);
90  }
91 
92  static void delete_connection(
93  void *native_adapter_data,
94  RTI_RoutingServiceConnectionExt *native_connection,
95  RTI_RoutingServiceEnvironment *environment)
96  {
97  ConnectionForwarder::delete_native(
98  static_cast<AdapterPlugin *>(native_adapter_data),
99  native_connection,
100  environment);
101  }
102 
103 };
104 
105 
106 }}}}
107 
108 #endif // RTI_ROUTING_ADAPTER_DETAIL_ADAPTER_FORWARDER_HPP_

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