18#ifndef RTI_ROUTING_PROCESSOR_SAMPLE_ITERATOR_HPP_
19 #define RTI_ROUTING_PROCESSOR_SAMPLE_ITERATOR_HPP_
22 #include <rti/routing/processor/LoanedSample.hpp>
32struct no_sample_info_t {
43template <
typename T,
typename U>
47 using iterator_category = std::random_access_iterator_tag;
48 using value_type =
const LoanedSample<T, U>;
49 using reference = value_type;
50 using pointer = value_type;
51 using difference_type = std::size_t;
52 using SampleSeqType = RTI_RoutingServiceSample*;
53 using InfoSeqType = RTI_RoutingServiceSampleInfo*;
56 static no_sample_info_t *_null_info_scrachtpad[1];
57 static InfoSeqType _null_info_seq;
58 static difference_type _null_info_pos;
71 const SampleSeqType sample_seq,
72 const InfoSeqType info_seq,
75 : _sample_seq(sample_seq),
76 _info_seq(info_seq == NULL ? _null_info_seq : info_seq),
78 _info_pos(info_seq == NULL ? _null_info_pos : _pos)
81 throw dds::core::IllegalOperationError(
"SampleIterator out of range");
84 _pos =
static_cast<difference_type
>(position);
88 : _sample_seq(other._sample_seq),
89 _info_seq(other._info_seq),
90 _length(other._length),
92 _info_pos(other._info_pos)
98 _sample_seq = other._sample_seq;
99 _info_seq = other._info_seq;
100 _length = other._length;
102 _info_pos = other._info_pos;
107 value_type operator*()
const
109 return value_type(_sample_seq[_pos], _info_seq[_info_pos]);
112 value_type operator->()
const
114 return value_type(_sample_seq[_pos], _info_seq[_info_pos]);
117 value_type operator[](difference_type offset)
const
119 return (_info_seq == _null_info_seq)
120 ? value_type(_sample_seq[_pos], NULL)
121 : value_type(_sample_seq[_pos + offset], _info_seq[_info_pos + offset]);
134 if (_pos == std::numeric_limits<difference_type>::max()) {
135 throw dds::core::IllegalOperationError(
"SampleIterator out of range");
151 if (_pos == std::numeric_limits<difference_type>::min()) {
152 throw dds::core::IllegalOperationError(
"SampleIterator out of range");
169 throw dds::core::IllegalOperationError(
"SampleIterator out of range");
178 if ((std::numeric_limits<difference_type>::max() - _pos) < i) {
179 throw dds::core::IllegalOperationError(
"SampleIterator out of range");
204 friend difference_type operator-(
208 return s1._pos - s2._pos;
214 return s1._pos < s2._pos;
220 return s1._pos > s2._pos;
226 return s1._pos <= s2._pos;
232 return s1._pos >= s2._pos;
238 return (s1._sample_seq == s2._sample_seq) && (s1._pos == s2._pos);
249 return (_length == _pos);
255 SampleSeqType _sample_seq;
256 InfoSeqType _info_seq;
258 difference_type _pos;
259 difference_type& _info_pos;
263template <
typename T,
typename U>
266template <
typename T,
typename U>
269template <
typename T,
typename U>
270typename SampleIterator<T, U>::InfoSeqType SampleIterator<T, U>::_null_info_seq =
271reinterpret_cast<InfoSeqType
> (SampleIterator<T, U>::_null_info_scrachtpad);
A random-access iterator of LoanedSample.
Definition: SampleIterator.hpp:44