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>
29namespace rti {
namespace routing {
namespace processor {
31template <
typename T,
typename U>
class TypedInput;
80template <
typename T,
typename U = dds::sub::SampleInfo>
85 typedef typename std::vector<StreamReader::SamplePtr> SampleSeqType;
86 typedef typename std::vector<StreamReader::InfoPtr> InfoSeqType;
93 typedef typename SampleIterator<T, U>::value_type value_type;
94 typedef std::ptrdiff_t difference_type;
101 native_samples_.data_array = NULL;
102 native_samples_.info_array = NULL;
103 native_samples_.length = 0;
110 RTI_RoutingServiceInput *native_input,
111 RTI_RoutingServiceLoanedSamples& native_samples)
112 : input_(native_input),
113 native_samples_(native_samples)
129 }
catch (
const std::exception&) {
147 return native_samples_.info_array == NULL
148 ? LoanedSample<T, U>(native_samples_.data_array[index], NULL)
149 : LoanedSample<T, U>(
150 native_samples_.data_array[index],
151 native_samples_.info_array[index]);
159 return native_samples_.length;
187 if (!RTI_RoutingServiceInput_return_loan(
190 throw dds::core::Error(
"error returning loaned samples to native input");
203 return (native_samples_.info_array != NULL);
213 native_samples_.data_array,
214 native_samples_.info_array,
215 native_samples_.length);
224 native_samples_.data_array,
225 native_samples_.info_array,
226 native_samples_.length,
227 native_samples_.length);
236 native_samples_.data_array,
237 native_samples_.info_array,
238 native_samples_.length);
247 native_samples_.data_array,
248 native_samples_.info_array,
249 native_samples_.length,
250 native_samples_.length);
258 std::swap(input_, other.input_);
259 std::swap(native_samples_, other.native_samples_);
262#if !defined(RTI_CXX11_RVALUE_REFERENCES)
265 MoveProxy() : input_(NULL)
267 native_samples_.data_array = NULL;
268 native_samples_.info_array = NULL;
269 native_samples_.length = 0;
272 RTI_RoutingServiceInput *input_;
273 RTI_RoutingServiceLoanedSamples native_samples_;
277 : input_(proxy.input_),
278 native_samples_(proxy.native_samples_)
291 operator MoveProxy () throw()
296 std::swap(input_, proxy.input_);
297 std::swap(native_samples_, proxy.native_samples_);
314 native_samples_.data_array = NULL;
315 native_samples_.info_array = NULL;
316 native_samples_.length = 0;
332 friend class TypedInput<T, U>;
339 RTI_RoutingServiceLoanedSamples& native_samples()
341 return native_samples_;
346 RTI_RoutingServiceInput *input_;
347 RTI_RoutingServiceLoanedSamples native_samples_;
351template <
typename T,
typename U>
352LoanedSamples<T, U> move(LoanedSamples<T,U> & ls) OMG_NOEXCEPT
354#if defined(RTI_CXX11_RVALUE_REFERENCES)
355 return std::move(ls);
357 return LoanedSamples<T,U>(
typename LoanedSamples<T,U>::MoveProxy(ls));
Provides a way to read samples of a specific type from a data domain. In the XML configuration file,...
Definition: StreamReader.hpp:45
Provides temporary access to a collection of samples (data and info) from a TypedInput.
Definition: LoanedSamples.hpp:81
SampleIterator< T, U > iterator
The iterator type.
Definition: LoanedSamples.hpp:91
int32_t length() const
Gets the number of samples in this collection.
Definition: LoanedSamples.hpp:157
const_iterator end() const
Gets an iterator to one past the last sample.
Definition: LoanedSamples.hpp:244
iterator end()
Gets an iterator to one past the last sample.
Definition: LoanedSamples.hpp:221
LoanedSample< T, U > operator[](size_t index)
Provides access to the underlying LoanedSample object in array-like syntax.
Definition: LoanedSamples.hpp:145
bool has_infos()
Returns whether the Info part is available for each Data item of this set of loaned samples.
Definition: LoanedSamples.hpp:201
const_iterator begin() const
Gets an iterator to the first sample.
Definition: LoanedSamples.hpp:233
void swap(LoanedSamples &other)
Swaps two LoanedSamples containers.
Definition: LoanedSamples.hpp:256
iterator begin()
Gets an iterator to the first sample.
Definition: LoanedSamples.hpp:210
LoanedSamples()
Creates an empty LoanedSamples object.
Definition: LoanedSamples.hpp:99
void return_loan()
Returns the samples to the TypedInput used to get these samples.
Definition: LoanedSamples.hpp:184
~LoanedSamples()
Automatically returns the loan to the TypedInput used to obtained these samples.
Definition: LoanedSamples.hpp:125
A random-access iterator of LoanedSample.
Definition: SampleIterator.hpp:44