RTI Routing Service Version 7.7.0
TransformationPluginForwarder.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_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_
12#define RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_
13
14#include <rti/core/Exception.hpp>
15
16#include <routingservice/routingservice_transformation.h>
17
18#include <rti/routing/transf/detail/TransformationForwarder.hpp>
19
20namespace rti { namespace routing { namespace transf { namespace detail {
21
22
23class TransformationPluginForwarder {
24public:
25 static RTI_RoutingServiceTransformationPlugin * create_plugin(
26 TransformationPlugin *transformation_plugin)
27 {
28 RTI_RoutingServiceTransformationPlugin *native_plugin = NULL;
29 RTIOsapiHeap_allocateStructure(
30 &native_plugin,
31 struct RTI_RoutingServiceTransformationPlugin);
32 rti::core::check_create_entity(
33 native_plugin,
34 "RTI_RoutingServiceTransformationPlugin");
35 RTI_RoutingServiceTransformationPlugin_initialize(native_plugin);
36
37 // Set adapter version
38 rti::config::LibraryVersion version = transformation_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 // Initiallize adapter methods
44 native_plugin->user_object = static_cast<void *>(transformation_plugin);
45 native_plugin->transformation_plugin_delete =
46 TransformationPluginForwarder::delete_plugin;
47 native_plugin->transformation_plugin_create_transformation =
48 TransformationPluginForwarder::create_transformation;
49 native_plugin->transformation_plugin_delete_transformation =
50 TransformationPluginForwarder::delete_transformation;
51 native_plugin->transformation_transform =
52 TransformationForwarder::transform;
53 native_plugin->transformation_return_loan =
54 TransformationForwarder::return_loan;
55 native_plugin->transformation_update =
56 TransformationForwarder::update;
57
58 return native_plugin;
59 }
60
61 static void delete_plugin(
62 RTI_RoutingServiceTransformationPlugin *native_plugin,
63 RTI_RoutingServiceEnvironment *)
64 {
65 TransformationPlugin *plugin = static_cast<TransformationPlugin *>(
66 native_plugin->user_object);
67 // Plug-in is destructor not allowed to throw
68 delete plugin;
69 RTIOsapiHeap_freeStructure(native_plugin);
70 }
71
72 static RTI_RoutingServiceTransformation create_transformation(
73 struct RTI_RoutingServiceTransformationPlugin *native_plugin,
74 const struct RTI_RoutingServiceTypeInfo *input_type_info,
75 const struct RTI_RoutingServiceTypeInfo *output_type_info,
76 const struct RTI_RoutingServiceProperties *native_properties,
77 RTI_RoutingServiceEnvironment *environment)
78 {
79 return TransformationForwarder::create_native(
80 static_cast<TransformationPlugin *>(native_plugin->user_object),
81 input_type_info,
82 output_type_info,
83 native_properties,
84 environment);
85
86 }
87
88 static void delete_transformation(
89 struct RTI_RoutingServiceTransformationPlugin *native_plugin,
90 RTI_RoutingServiceTransformation native_transformation,
91 RTI_RoutingServiceEnvironment *environment)
92 {
93 TransformationForwarder::delete_native(
94 static_cast<TransformationPlugin *>(native_plugin->user_object),
95 native_transformation,
96 environment);
97 }
98
99};
100
101
102}}}}
103
104#endif // RTI_ROUTING_TRANSF_DETAIL_TRANSFORMATION_PLUGIN_FORWARDER_HPP_