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 <rti/routing/processor/LoanedSample.hpp>
25 #include <rti/routing/adapter/StreamReader.hpp>
26 #include <rti/routing/processor/SampleIterator.hpp>
28 namespace rti {
namespace routing {
namespace processor {
30 template <
typename T,
typename U>
class TypedInput;
34 struct NativeSamples {
38 NativeSamples() : sample_array_(NULL), info_array_(NULL), length_(0)
42 RTI_RoutingServiceSample *sample_array_;
43 RTI_RoutingServiceSampleInfo *info_array_;
95 template <
typename T,
typename U = dds::sub::SampleInfo>
100 typedef typename std::vector<StreamReader::SamplePtr> SampleSeqType;
101 typedef typename std::vector<StreamReader::InfoPtr> InfoSeqType;
108 typedef typename SampleIterator<T, U>::value_type value_type;
109 typedef std::ptrdiff_t difference_type;
121 RTI_RoutingServiceStreamReaderExt *native_reader,
122 detail::NativeSamples& native_samples,
123 RTI_RoutingServiceEnvironment *native_env)
124 : reader_(native_reader),
125 native_samples_(native_samples),
126 native_env_(native_env)
142 }
catch (
const std::exception& ex) {
160 return LoanedSample<T,U>(
161 native_samples_.sample_array_[index],
162 native_samples_.info_array_[index]);
170 return native_samples_.length_;
198 reader_->return_loan(
199 reader_->stream_reader_data,
200 native_samples_.sample_array_,
201 native_samples_.info_array_,
202 native_samples_.length_,
204 RTI_ROUTING_THROW_ON_ENV_ERROR(native_env_);
216 native_samples_.sample_array_,
217 native_samples_.info_array_,
218 native_samples_.length_,
228 native_samples_.sample_array_,
229 native_samples_.info_array_,
230 native_samples_.length_,
231 native_samples_.length_);
240 native_samples_.sample_array_,
241 native_samples_.info_array_,
251 native_samples_.sample_array_,
252 native_samples_.info_array_,
253 native_samples_.length_);
261 std::swap(reader_, other.reader_);
262 std::swap(native_samples_, other.native_samples_);
263 std::swap(native_env_, other.native_env_);
266 #if !defined(RTI_CXX11_RVALUE_REFERENCES)
269 MoveProxy() : reader_(NULL)
273 RTI_RoutingServiceStreamReaderExt *reader_;
274 detail::NativeSamples native_samples_;
275 RTI_RoutingServiceEnvironment *native_env_;
279 : reader_(proxy.reader_),
280 native_samples_(proxy.native_samples_),
281 native_env_(proxy.native_env_)
294 operator MoveProxy () throw()
299 std::swap(reader_, proxy.reader_);
300 std::swap(native_samples_, proxy.native_samples_);
301 std::swap(native_env_, proxy.native_env_);
316 :reader_(NULL), native_env_(NULL)
330 #endif // !defined(RTI_CXX11_RVALUE_REFERENCES)
333 friend class TypedInput<T, U>;
340 detail::NativeSamples& native_samples()
342 return native_samples_;
347 return native_samples_.info_array_ != NULL;
352 RTI_RoutingServiceStreamReaderExt *reader_;
353 detail::NativeSamples native_samples_;
354 RTI_RoutingServiceEnvironment *native_env_;
358 template <
typename T,
typename U>
359 LoanedSamples<T, U> move(LoanedSamples<T,U> & ls) OMG_NOEXCEPT
361 #if defined(RTI_CXX11_RVALUE_REFERENCES)
362 return std::move(ls);
364 return LoanedSamples<T,U>(
typename LoanedSamples<T,U>::MoveProxy(ls));
371 #endif // RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_