11 #ifndef RTI_DDS_FLAT_SEQUENCEITERATOR_HPP_
12 #define RTI_DDS_FLAT_SEQUENCEITERATOR_HPP_
16 #include "rti/flat/Offset.hpp"
18 namespace rti {
namespace flat {
43 template <
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_;
344 #endif // RTI_DDS_FLAT_SEQUENCEITERATOR_HPP_