RTI Routing Service Version 7.7.0
routingservice_transformation.h
Go to the documentation of this file.
1/*
2 * (c) Copyright, Real-Time Innovations, 2002-2024.
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 routingservice_transformation_h
12#define routingservice_transformation_h
13
15
16#ifdef __cplusplus
17 extern "C" {
18#endif
19
20/*e \file
21 @brief RTI Routing Service Transformation API
22*/
23
24/*e \defgroup RTI_RoutingServiceTransformationModule RTI Routing Service Transformation API
25 \ingroup ROUTER
26 @brief This module describes the Transformation API.
27
28 An \product route transforms the incoming data using a \em transformation, which is an
29 object created by a transformation plugin.<br>
30
31 Transformation plugins implement the transformation API described in this module and
32 must be provided as shared libraries that RTI \product will load dynamically.
33
34 To register a transformation plugin with \product, you must use the tag
35 &lt;transformation_plugin&gt; within &lt;transformation_library&gt;. For example:
36
37 \verbatim
38 <dds>
39 ...
40 <transformation_library name="MyTransfLib">
41 <transformation_plugin name="MyTransfPlugin">
42 <dll>mytransformation</dll>
43 <create_function>
44 MyTransfPlugin_create
45 </create_function>
46 </transformation_plugin>
47 ...
48 </transformation_library>
49 ...
50 <routing_service>
51 ...
52 </routing_service>
53 ...
54 </dds>
55 \endverbatim
56
57 Once a transformation plugin is registered, an Output can use it to create a data transformation.
58 For example:
59
60 \verbatim
61 <topic_route name="SquareSwitchCoord">
62 <input participant="1">
63 <topic_name>Square</topic_name>
64 <registered_type_name>ShapeType</registered_type_name>
65 </input>
66 <output>
67 <topic_name>Square</topic_name>
68 <registered_type_name>ShapeType</registered_type_name>
69 </output>
70 <transformation plugin_name="MyTransfLib::MyTransPlugin">
71 <property>
72 <value>
73 <element>
74 <name>X</name>
75 <value>Y</value>
76 </element>
77 <element>
78 <name>Y</name>
79 <value>X</value>
80 </element>
81 </value>
82 </property>
83 </transformation>
84 </topic_route>
85 \endverbatim
86
87 For additional information on configuring transformations, see the \ref_url_routing_service_users_manual.
88
89 \section Requirements Development Requirements
90
91 <table border="1" cellspacing="1">
92 <tr>
93 <td></td>
94 <td>Linux or macOS Systems</td>
95 <td>Windows Systems</td>
96 </tr>
97 <tr>
98 <td><b>Shared Library</b></td>
99 <td>librtirsinfrastructure.so<br>
100 <br>
101 If the transformation must work with adapters providing DDS_DynamicData or DDS_SampleInfo (such as the built-in DDS adapter):<br>
102 libnddsc.so and libnddscore.so
103 </td>
104 <td>rtirsinfrastructure.dll<br>
105 <br>
106 If the transformation must work with adapters providing DDS_DynamicData or DDS_SampleInfo (such as the built-in DDS adapter):<br>
107 nddsc.dll and nddscore.dll
108 </td>
109 </tr>
110 <tr>
111 <td><b>Header</b></td>
112 <td colspan="2">
113 routingservice_transformation.h<br>
114 <br>
115 If the transformation must work with adapters providing DDS_DynamicData or DDS_SampleInfo (such as the built-in DDS adapter):
116 ndds_c.h
117 </td>
118 </tr>
119 </table>
120*/
122
123/*e \ingroup RTI_RoutingServiceTransformationModule
124 \brief Transformation.
125
126 A route can transform the incoming data using transformation objects.
127
128 The transformation objects are created by transformation plugins.
129*/
131
132/*e \ingroup RTI_RoutingServiceTransformationModule
133 \brief Prototype of the function that creates a transformation plugin.
134
135 The name of the function that implements this prototype
136 must be provided to \product using the tag &lt;create_function&gt;
137 when the transformation plugin is registered.
138
139 For example:
140
141 \verbatim
142 <plugin_library name="MyTransfLib">
143 <transformation_plugin name="MyTransfPlugin">
144 <dll>mytransformation</dll>
145 <create_function>
146 MyTransfPlugin_create
147 </create_function>
148 </transformation_plugin>
149 ...
150 </plugin_library>
151 \endverbatim
152
153 This is the only function that is not part of
154 \ref RTI_RoutingServiceTransformationPlugin.
155
156 <b>Required:</b> yes
157
158 @param properties \rs_st_in Configuration properties for the transformation.
159
160 @param env \rs_st_inout Environment for error indications.
161
162 @return New plugin instance if successful. Otherwise, NULL.
163
164 @see \ref RTI_RoutingServiceTransformationPlugin_DeleteFcn
165*/
168 const struct RTI_RoutingServiceProperties *properties,
170
171/*e \ingroup RTI_RoutingServiceTransformationModule
172 \brief Prototype of the function that deletes a transformation plugin.
173
174 Transformation plugins are deleted when \product is closed.
175
176 <b>Required:</b> yes
177
178 @param plugin \rs_st_in Transformation plugin to be deleted.
179 @param env \rs_st_inout Environment for error indications.
180
181 @see \ref RTI_RoutingServiceTransformationPlugin_CreateFcn
182*/
186
187/*e \ingroup RTI_RoutingServiceTransformationModule
188 \brief Prototype of the function that creates a route transformation.
189
190 This function is called when the route containing the transformation
191 is ready to forward data.
192
193 The format associated with the input and output types depends on
194 the format provided by the route adapters.
195
196 For the built-in DDS adapter, the format of the types is DDS_TypeCode.
197
198 <b>Required:</b> yes
199
200 @param plugin \rs_st_in Transformation plugin that will be used to create the transformation.
201 @param input_type_info \rs_st_in Type information associated with the input samples.
202 @param output_type_info \rs_st_in Type information associated with the output samples.
203 @param properties \rs_st_in Configuration properties for the transformation.
204 These properties corresponds to the properties specified within the tag &lt;transformation&gt;.
205 @param env \rs_st_inout Environment for error indications.
206
207 @return New transformation if successful. Otherwise, error.
208
209 @see \ref RTI_RoutingServiceTransformationPlugin_DeleteTransformationFcn
210*/
214 const struct RTI_RoutingServiceTypeInfo *input_type_info,
215 const struct RTI_RoutingServiceTypeInfo *output_type_info,
218
219/*e \ingroup RTI_RoutingServiceTransformationModule
220 \brief Prototype of the function that deletes a transformation.
221
222 This function is called when the route containing the transformation is disabled.
223
224 @param plugin \rs_st_in Transformation plugin that will be used to delete the transformation.
225 @param transformation \rs_st_in Transformation to be deleted.
226 @param env \rs_st_inout Environment for error indications.
227
228 @see \ref RTI_RoutingServiceTransformationPlugin_CreateTransformationFcn
229*/
234
235/*e \ingroup RTI_RoutingServiceTransformationModule
236
237 \brief Prototype of the function that transforms a sequence of input
238 samples into a sequence of output samples.
239
240 When \product is done using the output samples, it will 'return the loan'
241 to the transformation by calling \ref RTI_RoutingServiceTransformation_ReturnLoanFcn.
242
243 The number of output samples can be different than the number of input samples.
244
245 The memory used by the output samples and sample infos is managed by the transformation.
246 The transformation must allocate the memory for the output samples and sample infos
247 and free it when \product calls \ref RTI_RoutingServiceTransformation_ReturnLoanFcn.
248
249 The format associated with the input and output samples and sample infos depends on
250 the format provided and consumed by the route StreamReader and StreamWriter.
251
252 For the built-in DDS adapter, the format of the samples is DDS_DynamicData and the format
253 of the sample info is DDS_SampleInfo.
254
255 <b>Required:</b> yes
256
257 @param transformation \rs_st_in Transformation that will transform the samples.
258 @param out_sample_lst \rs_st_out Array that will hold the output samples.
259 This array will be provided by the transformation. *Note*: A transformation
260 cannot return the input sample array as the output sample array;
261 otherwise \product will fail. In general, the memory used for the output samples
262 should be managed by the transformation.
263 @param out_info_lst \rs_st_out Array that will hold the output sample infos.
264 This array will be provided by the transformation. *Note*: A transformation
265 cannot return the input sample info array as the output info array;
266 otherwise \product will fail. In general, the memory used for the
267 output sample infos should be managed by the transformation and freed when
268 \product calls \ref RTI_RoutingServiceTransformation_ReturnLoanFcn.
269 @param out_count \rs_st_out Number of output samples. The value must be greater
270 than or equal to zero.
271 @param in_sample_lst \rs_st_in Array of input samples.
272 @param in_info_lst \rs_st_in Array of input sample infos.
273 @param in_count \rs_st_in Number of input samples.
274 @param env \rs_st_inout Environment for error indications.
275
276 @see \ref RTI_RoutingServiceTransformation_ReturnLoanFcn
277*/
280 RTI_RoutingServiceSample **out_sample_lst,
281 RTI_RoutingServiceSampleInfo **out_info_lst,
282 int *out_count,
283 RTI_RoutingServiceSample *in_sample_lst,
284 RTI_RoutingServiceSampleInfo *in_info_lst,
285 int in_count,
287
288/*e \ingroup RTI_RoutingServiceTransformationModule
289 \brief Prototype of the function that returns the loan on the output samples
290 and infos.
291
292 This function is called by \product to indicate that it is done accessing the
293 array of data samples obtained by an earlier invocation of
294 \ref RTI_RoutingServiceTransformation_TransformFcn.
295
296 The memory used by the output samples and sample infos is managed by the
297 transformation and should be freed in this call if it was allocated when
298 \product calls \ref RTI_RoutingServiceTransformation_ReturnLoanFcn.
299
300 <b>Required:</b> yes
301
302 @param transformation \rs_st_in Transformation that owns the samples and sample infos.
303 @param sample_lst \rs_st_in Array of samples.
304 @param info_lst \rs_st_in Array of sample infos.
305 @param count \rs_st_in Number of samples in the array.
306 @param env \rs_st_inout Environment for error indications.
307*/
310 RTI_RoutingServiceSample *sample_lst,
312 int count,
314
315/*e \ingroup RTI_RoutingServiceTransformationModule
316 \brief Prototype of the function that updates a transformation configuration.
317
318 @param transformation \rs_st_in Transformation.
319 @param properties \rs_st_in New configuration properties.
320 @param env \rs_st_inout Environment for error indications.
321*/
326
327/*e \ingroup RTI_RoutingServiceTransformationModule
328 \brief Transformation plugin.
329
330 This structure contains the plugin implementation as a set of function pointers.
331*/
333 int _init;
334 struct RTI_RoutingServiceVersion _rs_version;
335
336 /*e \brief The version of this transformation plugin */
338
339 /*e \brief Handles the deletion of the transformation plugin. */
342 /*e \brief Handles the creation of transformations. */
345 /*e \brief Handles the deletion of transformations. */
348
349 /*e \brief Handles the transformation of samples. */
351 /*e \brief Handles the return of the loan taken on the transformed samples. */
353 /*e \brief Handles the update of the transformation configuration. */
355
356 /*e @brief A place for transformation implementors to keep a pointer to data that
357 may be needed by the implementation. */
359};
360
361
362
363#define RTI_ROUTING_SERVICE_TRANSFORMATION_PLUGIN_INIT_NUMBER (9876543)
364/*e \ingroup RTI_RoutingServiceTransformationModule
365 \hideinitializer
366 @brief Initializes the plugin structure.
367
368 This macro must be called to initialize the
369 return value of RTI_RoutingServiceTransformationPlugin_CreateFcn
370
371 @param transf Pointer to the transformation plugin structure
372
373 @see \ref RTI_RoutingServiceTransformationPlugin_CreateFcn
374*/
375#define RTI_RoutingServiceTransformationPlugin_initialize(transf) \
376{ \
377 struct RTI_RoutingServiceVersion rsVersion = RTI_ROUTING_SERVICE_VERSION; \
378 struct RTI_RoutingServiceVersion transfVersion = {0,0,0,0}; \
379 (transf)->_init = RTI_ROUTING_SERVICE_TRANSFORMATION_PLUGIN_INIT_NUMBER; \
380 (transf)->_rs_version = rsVersion; \
381 (transf)->plugin_version = transfVersion; \
382 (transf)->transformation_plugin_delete = 0; \
383 (transf)->transformation_plugin_create_transformation = 0; \
384 (transf)->transformation_plugin_delete_transformation = 0; \
385 (transf)->transformation_transform = 0; \
386 (transf)->transformation_return_loan = 0; \
387 (transf)->transformation_update = 0; \
388 (transf)->user_object = 0; \
389}
390
391#ifdef __cplusplus
392} /* extern "C" */
393#endif
394
395#endif /* routingservice_transformation_h */
struct RTI_RoutingServiceEnvironmentImpl RTI_RoutingServiceEnvironment
The environment permits the return of error information in the RTI Routing Service API and informatio...
Definition: routingservice_infrastructure.h:183
void * RTI_RoutingServiceSample
Stream sample.
Definition: routingservice_infrastructure.h:482
void * RTI_RoutingServiceSampleInfo
Stream sample info. In DDS, this is a DDS_SampleInfo object.
Definition: routingservice_infrastructure.h:489
void * RTI_RoutingServiceTransformation
Transformation.
Definition: routingservice_transformation.h:121
RTI_RoutingServiceTransformation(* RTI_RoutingServiceTransformationPlugin_CreateTransformationFcn)(struct RTI_RoutingServiceTransformationPlugin *plugin, const struct RTI_RoutingServiceTypeInfo *input_type_info, const struct RTI_RoutingServiceTypeInfo *output_type_info, const struct RTI_RoutingServiceProperties *properties, RTI_RoutingServiceEnvironment *env)
Prototype of the function that creates a route transformation.
Definition: routingservice_transformation.h:212
void(* RTI_RoutingServiceTransformationPlugin_DeleteFcn)(struct RTI_RoutingServiceTransformationPlugin *plugin, RTI_RoutingServiceEnvironment *env)
Prototype of the function that deletes a transformation plugin.
Definition: routingservice_transformation.h:183
void(* RTI_RoutingServiceTransformation_UpdateFcn)(RTI_RoutingServiceTransformation transformation, const struct RTI_RoutingServiceProperties *properties, RTI_RoutingServiceEnvironment *env)
Prototype of the function that updates a transformation configuration.
Definition: routingservice_transformation.h:322
void(* RTI_RoutingServiceTransformation_TransformFcn)(RTI_RoutingServiceTransformation transformation, RTI_RoutingServiceSample **out_sample_lst, RTI_RoutingServiceSampleInfo **out_info_lst, int *out_count, RTI_RoutingServiceSample *in_sample_lst, RTI_RoutingServiceSampleInfo *in_info_lst, int in_count, RTI_RoutingServiceEnvironment *env)
Prototype of the function that transforms a sequence of input samples into a sequence of output sampl...
Definition: routingservice_transformation.h:278
void(* RTI_RoutingServiceTransformationPlugin_DeleteTransformationFcn)(struct RTI_RoutingServiceTransformationPlugin *plugin, RTI_RoutingServiceTransformation transformation, RTI_RoutingServiceEnvironment *env)
Prototype of the function that deletes a transformation.
Definition: routingservice_transformation.h:230
struct RTI_RoutingServiceTransformationPlugin *(* RTI_RoutingServiceTransformationPlugin_CreateFcn)(const struct RTI_RoutingServiceProperties *properties, RTI_RoutingServiceEnvironment *env)
Prototype of the function that creates a transformation plugin.
Definition: routingservice_transformation.h:167
void(* RTI_RoutingServiceTransformation_ReturnLoanFcn)(RTI_RoutingServiceTransformation transformation, RTI_RoutingServiceSample *sample_lst, RTI_RoutingServiceSampleInfo *info_lst, int count, RTI_RoutingServiceEnvironment *env)
Prototype of the function that returns the loan on the output samples and infos.
Definition: routingservice_transformation.h:308
RTI Routing Service Infrastructure.
Set of configuration properties.
Definition: routingservice_infrastructure.h:77
struct RTI_RoutingServiceNameValue * properties
Array of configuration properties.
Definition: routingservice_infrastructure.h:79
Transformation plugin.
Definition: routingservice_transformation.h:332
RTI_RoutingServiceTransformationPlugin_DeleteTransformationFcn transformation_plugin_delete_transformation
Handles the deletion of transformations.
Definition: routingservice_transformation.h:347
RTI_RoutingServiceTransformationPlugin_DeleteFcn transformation_plugin_delete
Handles the deletion of the transformation plugin.
Definition: routingservice_transformation.h:341
struct RTI_RoutingServiceVersion plugin_version
The version of this transformation plugin.
Definition: routingservice_transformation.h:337
RTI_RoutingServiceTransformationPlugin_CreateTransformationFcn transformation_plugin_create_transformation
Handles the creation of transformations.
Definition: routingservice_transformation.h:344
void * user_object
A place for transformation implementors to keep a pointer to data that may be needed by the implement...
Definition: routingservice_transformation.h:358
RTI_RoutingServiceTransformation_TransformFcn transformation_transform
Handles the transformation of samples.
Definition: routingservice_transformation.h:350
RTI_RoutingServiceTransformation_ReturnLoanFcn transformation_return_loan
Handles the return of the loan taken on the transformed samples.
Definition: routingservice_transformation.h:352
RTI_RoutingServiceTransformation_UpdateFcn transformation_update
Handles the update of the transformation configuration.
Definition: routingservice_transformation.h:354
Type information.
Definition: routingservice_infrastructure.h:438
Represents the version of a plugin or RTI Routing Service itself.
Definition: routingservice_infrastructure.h:190