11#ifndef RTI_DDS_FLAT_SEQUENCEITERATOR_HPP_
12#define RTI_DDS_FLAT_SEQUENCEITERATOR_HPP_
16#include "rti/flat/Offset.hpp"
18namespace rti {
namespace flat {
43template <
typename E,
typename OffsetKind>
79 rti::flat::SampleBase *sample,
80 offset_t initial_offset,
83 current_offset_(initial_offset),
84 max_offset_(max_offset)
86 RTI_FLAT_ASSERT(sample != NULL,
return);
94 return sample_ == NULL;
107 return get_impl(OffsetKind());
115 return get_impl(OffsetKind());
136 return advance_impl(OffsetKind());
149 bool can_advance_iter = advance_impl(OffsetKind());
150 RTI_FLAT_CHECK_PRECONDITION(can_advance_iter,
return *
this);
176 return s1.get_position() < s2.get_position();
186 return s1.get_position() > s2.get_position();
196 return s1.get_position() <= s2.get_position();
206 return s1.get_position() >= s2.get_position();
216 return s1.get_position() == s2.get_position();
229 unsigned char * get_position()
const
234 return sample_->get_buffer() + current_offset_;
239 E get_impl(variable_size_type_tag_t)
const
248 offset_t offset = RTIXCdrAlignment_alignSizeUp(current_offset_, 4);
250 if (offset >= max_offset_) {
258 offset_t size = E::Helper::calculate_serialized_size(
269 return E(sample_, offset, size);
272 E get_impl(fixed_size_type_tag_t)
const
280 offset_t offset = RTIXCdrAlignment_alignSizeUp(
282 E::required_alignment);
283 if (offset >= max_offset_) {
287 return E(sample_, offset);
290 bool advance_impl(variable_size_type_tag_t)
296 current_offset_ = RTIXCdrAlignment_alignSizeUp(current_offset_, 4);
297 offset_t size = E::Helper::calculate_serialized_size(
305 current_offset_ += size;
307 if (current_offset_ > max_offset_) {
308 current_offset_ = max_offset_;
315 bool advance_impl(fixed_size_type_tag_t)
324 current_offset_ = RTIXCdrAlignment_alignSizeUp(
326 E::required_alignment);
327 current_offset_ += E::serialized_size(0);
329 if (current_offset_ > max_offset_) {
330 current_offset_ = max_offset_;
337 rti::flat::SampleBase *sample_;
338 offset_t current_offset_;
339 offset_t max_offset_;
Iterator for collections of Offsets.
Definition: SequenceIterator.hpp:44
friend bool operator==(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:212
SequenceIterator operator++(int)
Advances to the next element.
Definition: SequenceIterator.hpp:162
friend bool operator<(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:172
value_type pointer
The pointer type is the same as the value type, an Offset.
Definition: SequenceIterator.hpp:64
SequenceIterator()
Constructs an invalid iterator.
Definition: SequenceIterator.hpp:74
friend bool operator>=(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:202
std::ptrdiff_t difference_type
The difference type.
Definition: SequenceIterator.hpp:69
value_type operator*() const
Returns the Offset of the current element.
Definition: SequenceIterator.hpp:105
friend bool operator>(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:182
E value_type
The element type.
Definition: SequenceIterator.hpp:54
bool is_null() const
Returns whether the iterator is invalid.
Definition: SequenceIterator.hpp:92
value_type reference
The reference type is the same as the value type, an Offset.
Definition: SequenceIterator.hpp:59
friend bool operator<=(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:192
SequenceIterator & operator++()
Advances to the next element.
Definition: SequenceIterator.hpp:147
bool advance()
Advances to the next element, reporting any errors by returning false.
Definition: SequenceIterator.hpp:132
value_type operator->() const
Returns the Offset of the current element.
Definition: SequenceIterator.hpp:113
friend bool operator!=(const SequenceIterator &s1, const SequenceIterator &s2)
Compares two iterators.
Definition: SequenceIterator.hpp:222
std::forward_iterator_tag iterator_category
The iterator category.
Definition: SequenceIterator.hpp:49
The RTI namespace.
Definition: AggregationBuilders.hpp:17