RTI Routing Service  Version 6.0.1
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
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 
21 namespace rti { namespace routing { namespace transf {
22 
36 public:
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 
121 template <typename Data, typename Info>
123 
124 public:
125 
129  typedef Data DataRep;
133  typedef Info InfoRep;
134 
137 
142  void transform(
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  }
201 private:
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 
216 typedef TypedTransformation<dds::core::xtypes::DynamicData, dds::sub::SampleInfo>
218 
219 
220 }}}
221 
222 
223 #endif // RTI_ROUTING_TRANSF_TRANSFORMATION_HPP_

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