RTI Routing Service Version 7.3.0
Transformation.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_TRANSFORMATION_HPP_
12#define RTI_ROUTING_TRANSF_TRANSFORMATION_HPP_
13
14#include <vector>
15
16#include <dds/core/xtypes/DynamicData.hpp>
17#include <dds/sub/SampleInfo.hpp>
18#include <rti/routing/UpdatableEntity.hpp>
19#include <rti/routing/detail/ForwarderUtils.hpp>
20
21namespace rti { namespace routing { namespace transf {
22
36public:
37
38 typedef void* SamplePtr;
39 typedef void* InfoPtr;
40
80 virtual void transform(
81 std::vector<SamplePtr>& output_sample_seq,
82 std::vector<InfoPtr>& output_info_seq,
83 const std::vector<SamplePtr>& input_sample_seq,
84 const std::vector<InfoPtr>& input_info_seq) = 0;
85
101 virtual void return_loan(
102 std::vector<SamplePtr>& sample_seq,
103 std::vector<InfoPtr>& info_seq) = 0;
104
105
106 virtual ~Transformation() {}
107};
108
109
121template <typename Data, typename Info>
123
124public:
125
129 typedef Data DataRep;
133 typedef Info InfoRep;
134
137
143 std::vector<SamplePtr>& output_sample_seq,
144 std::vector<InfoPtr>& output_info_seq,
145 const std::vector<SamplePtr>& input_sample_seq,
146 const std::vector<InfoPtr>& input_info_seq) RTI_FINAL
147 {
148 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(in_sample_seq_, input_sample_seq);
149 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(in_info_seq_, input_info_seq);
150 transform(
151 out_sample_seq_,
152 out_info_seq_,
153 in_sample_seq_,
154 in_info_seq_);
155 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(output_sample_seq, out_sample_seq_);
156 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(output_info_seq, out_info_seq_);
157 }
158
164 std::vector<SamplePtr>& sample_seq,
165 std::vector<InfoPtr>& info_seq) RTI_FINAL
166 {
167 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(out_sample_seq_, sample_seq);
168 RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS(out_info_seq_, info_seq);
169 return_loan(out_sample_seq_, out_info_seq_);
170 out_sample_seq_.clear();
171 out_info_seq_.clear();
172 }
173
179 virtual void transform(
180 std::vector<Data*>& output_sample_seq,
181 std::vector<Info*>& output_info_seq,
182 const std::vector<Data*>& input_sample_seq,
183 const std::vector<Info*>& input_info_seq) = 0;
184
190 virtual void return_loan(
191 std::vector<Data*>& sample_seq,
192 std::vector<Info*>& info_seq) = 0;
193
198 {
199
200 }
201private:
202 std::vector<Data*> in_sample_seq_;
203 std::vector<Info*> in_info_seq_;
204 std::vector<Data*> out_sample_seq_;
205 std::vector<Info*> out_info_seq_;
206
207};
208
216typedef TypedTransformation<dds::core::xtypes::DynamicData, dds::sub::SampleInfo>
218
219
220}}}
221
222
223#endif // RTI_ROUTING_TRANSF_TRANSFORMATION_HPP_
Defines a common interface for all the pluggable entities that can be updated at runtime.
Definition: UpdatableEntity.hpp:34
Provides a way to transform input samples into output samples of a different format and/or content.
Definition: Transformation.hpp:35
virtual void transform(std::vector< SamplePtr > &output_sample_seq, std::vector< InfoPtr > &output_info_seq, const std::vector< SamplePtr > &input_sample_seq, const std::vector< InfoPtr > &input_info_seq)=0
Transforms a vector of input samples into a vector of output samples.
virtual void return_loan(std::vector< SamplePtr > &sample_seq, std::vector< InfoPtr > &info_seq)=0
Returns a loan on the transformed data samples and info samples.
A wrapper implementation of a Transformation that provides a strongly-typed interface through templat...
Definition: Transformation.hpp:122
virtual void return_loan(std::vector< Data * > &sample_seq, std::vector< Info * > &info_seq)=0
Interface redefinition.
virtual void transform(std::vector< Data * > &output_sample_seq, std::vector< Info * > &output_info_seq, const std::vector< Data * > &input_sample_seq, const std::vector< Info * > &input_info_seq)=0
Interface redefinition.
Info InfoRep
The info type.
Definition: Transformation.hpp:133
void transform(std::vector< SamplePtr > &output_sample_seq, std::vector< InfoPtr > &output_info_seq, const std::vector< SamplePtr > &input_sample_seq, const std::vector< InfoPtr > &input_info_seq) RTI_FINAL
Performs the conversion between the vector of data and info pointers to strongly-type pointers.
Definition: Transformation.hpp:142
virtual ~TypedTransformation()
Virtual destructor.
Definition: Transformation.hpp:197
Data DataRep
The data type.
Definition: Transformation.hpp:129
void return_loan(std::vector< SamplePtr > &sample_seq, std::vector< InfoPtr > &info_seq) RTI_FINAL
Performs the conversion between the vector of data and info pointers to strongly-type pointers.
Definition: Transformation.hpp:163
TypedTransformation< dds::core::xtypes::DynamicData, dds::sub::SampleInfo > DynamicDataTransformation
Convenient definition of TypedTransformation that requires dds::core::xtypes::DynamicData for data sa...
Definition: Transformation.hpp:217