14 #ifndef RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_
15 #define RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_
17 #ifdef RTI_CXX11_RVALUE_REFERENCES
23 #include "routingservice/routingservice_adapter_new.h"
24 #include <dds/core/types.hpp>
25 #include <rti/routing/processor/LoanedSample.hpp>
26 #include <rti/routing/adapter/StreamReader.hpp>
27 #include <rti/routing/processor/SampleIterator.hpp>
29 namespace rti {
namespace routing {
namespace processor {
31 template <
typename T,
typename U>
class TypedInput;
35 struct NativeSamples {
39 NativeSamples() : sample_array_(NULL), info_array_(NULL), length_(0)
43 RTI_RoutingServiceSample *sample_array_;
44 RTI_RoutingServiceSampleInfo *info_array_;
96 template <
typename T,
typename U = dds::sub::SampleInfo>
101 typedef typename std::vector<StreamReader::SamplePtr> SampleSeqType;
102 typedef typename std::vector<StreamReader::InfoPtr> InfoSeqType;
109 typedef typename SampleIterator<T, U>::value_type value_type;
110 typedef std::ptrdiff_t difference_type;
122 RTI_RoutingServiceStreamReaderExt *native_reader,
123 detail::NativeSamples& native_samples,
124 RTI_RoutingServiceEnvironment *native_env)
125 : reader_(native_reader),
126 native_samples_(native_samples),
127 native_env_(native_env)
143 }
catch (
const std::exception& ex) {
161 return native_samples_.info_array_ == NULL
162 ? LoanedSample<T, U>(native_samples_.sample_array_[index], NULL)
163 : LoanedSample<T, U>(
164 native_samples_.sample_array_[index],
165 native_samples_.info_array_[index]);
173 return native_samples_.length_;
201 reader_->return_loan(
202 reader_->stream_reader_data,
203 native_samples_.sample_array_,
204 native_samples_.info_array_,
205 native_samples_.length_,
207 RTI_ROUTING_THROW_ON_ENV_ERROR(native_env_);
219 native_samples_.sample_array_,
220 native_samples_.info_array_,
221 native_samples_.length_);
230 native_samples_.sample_array_,
231 native_samples_.info_array_,
232 native_samples_.length_,
233 native_samples_.length_);
242 native_samples_.sample_array_,
243 native_samples_.info_array_,
244 native_samples_.length_);
253 native_samples_.sample_array_,
254 native_samples_.info_array_,
255 native_samples_.length_,
256 native_samples_.length_);
264 std::swap(reader_, other.reader_);
265 std::swap(native_samples_, other.native_samples_);
266 std::swap(native_env_, other.native_env_);
269 #if !defined(RTI_CXX11_RVALUE_REFERENCES)
272 MoveProxy() : reader_(NULL)
276 RTI_RoutingServiceStreamReaderExt *reader_;
277 detail::NativeSamples native_samples_;
278 RTI_RoutingServiceEnvironment *native_env_;
282 : reader_(proxy.reader_),
283 native_samples_(proxy.native_samples_),
284 native_env_(proxy.native_env_)
297 operator MoveProxy () throw()
302 std::swap(reader_, proxy.reader_);
303 std::swap(native_samples_, proxy.native_samples_);
304 std::swap(native_env_, proxy.native_env_);
319 :reader_(NULL), native_env_(NULL)
333 #endif // !defined(RTI_CXX11_RVALUE_REFERENCES)
336 friend class TypedInput<T, U>;
343 detail::NativeSamples& native_samples()
345 return native_samples_;
350 return native_samples_.info_array_ != NULL;
355 RTI_RoutingServiceStreamReaderExt *reader_;
356 detail::NativeSamples native_samples_;
357 RTI_RoutingServiceEnvironment *native_env_;
361 template <
typename T,
typename U>
362 LoanedSamples<T, U> move(LoanedSamples<T,U> & ls) OMG_NOEXCEPT
364 #if defined(RTI_CXX11_RVALUE_REFERENCES)
365 return std::move(ls);
367 return LoanedSamples<T,U>(
typename LoanedSamples<T,U>::MoveProxy(ls));
374 #endif // RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_