14#ifndef RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_
15#define RTI_ROUTING_PROCESSOR_LOANED_SAMPLES_HPP_
20#include "routingservice/routingservice_adapter_new.h"
21#include <dds/core/types.hpp>
22#include <rti/routing/processor/LoanedSample.hpp>
23#include <rti/routing/adapter/StreamReader.hpp>
24#include <rti/routing/processor/SampleIterator.hpp>
26namespace rti {
namespace routing {
namespace processor {
28template <
typename T,
typename U>
class TypedInput;
77template <
typename T,
typename U = dds::sub::SampleInfo>
82 typedef typename std::vector<StreamReader::SamplePtr> SampleSeqType;
83 typedef typename std::vector<StreamReader::InfoPtr> InfoSeqType;
90 typedef typename SampleIterator<T, U>::value_type value_type;
91 typedef std::ptrdiff_t difference_type;
98 native_samples_.data_array = NULL;
99 native_samples_.info_array = NULL;
100 native_samples_.length = 0;
107 RTI_RoutingServiceInput *native_input,
108 RTI_RoutingServiceLoanedSamples& native_samples)
109 : input_(native_input),
110 native_samples_(native_samples)
126 }
catch (
const std::exception&) {
144 return native_samples_.info_array == NULL
145 ? LoanedSample<T, U>(native_samples_.data_array[index], NULL)
146 : LoanedSample<T, U>(
147 native_samples_.data_array[index],
148 native_samples_.info_array[index]);
156 return native_samples_.length;
184 if (!RTI_RoutingServiceInput_return_loan(
187 throw dds::core::Error(
"error returning loaned samples to native input");
200 return (native_samples_.info_array != NULL);
210 native_samples_.data_array,
211 native_samples_.info_array,
212 native_samples_.length);
221 native_samples_.data_array,
222 native_samples_.info_array,
223 native_samples_.length,
224 native_samples_.length);
233 native_samples_.data_array,
234 native_samples_.info_array,
235 native_samples_.length);
244 native_samples_.data_array,
245 native_samples_.info_array,
246 native_samples_.length,
247 native_samples_.length);
255 std::swap(input_, other.input_);
256 std::swap(native_samples_, other.native_samples_);
262 native_samples_.data_array = NULL;
263 native_samples_.info_array = NULL;
264 native_samples_.length = 0;
278 friend class TypedInput<T, U>;
285 RTI_RoutingServiceLoanedSamples& native_samples()
287 return native_samples_;
292 RTI_RoutingServiceInput *input_;
293 RTI_RoutingServiceLoanedSamples native_samples_;
297template <
typename T,
typename U>
298LoanedSamples<T, U> move(LoanedSamples<T,U> & ls) OMG_NOEXCEPT
300 return std::move(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:78
SampleIterator< T, U > iterator
The iterator type.
Definition: LoanedSamples.hpp:88
int32_t length() const
Gets the number of samples in this collection.
Definition: LoanedSamples.hpp:154
const_iterator end() const
Gets an iterator to one past the last sample.
Definition: LoanedSamples.hpp:241
iterator end()
Gets an iterator to one past the last sample.
Definition: LoanedSamples.hpp:218
LoanedSample< T, U > operator[](size_t index)
Provides access to the underlying LoanedSample object in array-like syntax.
Definition: LoanedSamples.hpp:142
bool has_infos()
Returns whether the Info part is available for each Data item of this set of loaned samples.
Definition: LoanedSamples.hpp:198
const_iterator begin() const
Gets an iterator to the first sample.
Definition: LoanedSamples.hpp:230
void swap(LoanedSamples &other)
Swaps two LoanedSamples containers.
Definition: LoanedSamples.hpp:253
iterator begin()
Gets an iterator to the first sample.
Definition: LoanedSamples.hpp:207
LoanedSamples()
Creates an empty LoanedSamples object.
Definition: LoanedSamples.hpp:96
void return_loan()
Returns the samples to the TypedInput used to get these samples.
Definition: LoanedSamples.hpp:181
~LoanedSamples()
Automatically returns the loan to the TypedInput used to obtained these samples.
Definition: LoanedSamples.hpp:122
A random-access iterator of LoanedSample.
Definition: SampleIterator.hpp:44