19#ifndef FASTDDS_RTPS_COMMON__SEQUENCENUMBER_HPP
20#define FASTDDS_RTPS_COMMON__SEQUENCENUMBER_HPP
27#include <fastdds/fastdds_dll.hpp>
28#include <fastdds/rtps/common/Types.hpp>
29#include <fastdds/utils/fixed_size_bitmap.hpp>
68 : high(
static_cast<int32_t
>(u >> 32u))
69 , low(
static_cast<uint32_t
>(u))
78 return (
static_cast<uint64_t
>(high) << 32u) + low;
87 assert(std::numeric_limits<
decltype(high)>::max() > high);
110 uint32_t aux_low = low;
111 low +=
static_cast<uint32_t
>(inc);
116 assert(std::numeric_limits<
decltype(high)>::max() > high);
130#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
142 return (sn1.low == sn2.low) && (sn1.high == sn2.high);
155 return (sn1.low != sn2.low) || (sn1.high != sn2.high);
168 if (seq1.high == seq2.high)
170 return seq1.
low > seq2.low;
173 return seq1.high > seq2.high;
186 if (seq1.high == seq2.high)
188 return seq1.low < seq2.low;
191 return seq1.high < seq2.high;
204 if (seq1.high == seq2.high)
206 return seq1.low >= seq2.low;
209 return seq1.high > seq2.high;
222 if (seq1.high == seq2.high)
224 return seq1.low <= seq2.low;
227 return seq1.high < seq2.high;
238 const uint32_t inc)
noexcept
245 assert(0 < res.
high);
260 const uint32_t inc)
noexcept
264 if (res.
low < seq.low)
267 assert(std::numeric_limits<
decltype(res.
high)>::max() > res.
high);
284 assert(minuend >= subtrahend);
285 SequenceNumber_t res(minuend.high - subtrahend.high, minuend.low - subtrahend.low);
287 if (minuend.low < subtrahend.low)
289 assert(0 < res.
high);
300#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
322 std::ostream& output,
329 std::ostream& output,
330 const std::vector<SequenceNumber_t>& seqNumSet)
348 return static_cast<std::size_t
>(sequence_number.to64long());
370#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
379 std::ostream& output,
382 output << sns.
base().to64long() <<
":";
Template class to hold a range of items using a custom bitmap.
Definition fixed_size_bitmap.hpp:76
T base() const noexcept
Get base of the range.
Definition fixed_size_bitmap.hpp:131
void for_each(UnaryFunc f) const
Apply a function on every item on the range.
Definition fixed_size_bitmap.hpp:445
std::istream & operator>>(std::istream &input, EntityId_t &enP)
Definition EntityId_t.hpp:289
const SequenceNumber_t c_SequenceNumber_Unknown
Definition SequenceNumber.hpp:298
bool sort_seqNum(const SequenceNumber_t &s1, const SequenceNumber_t &s2) noexcept
Sorts two instances of SequenceNumber_t.
Definition SequenceNumber.hpp:308
bool operator==(const BuiltinTransportsOptions &bto1, const BuiltinTransportsOptions &bto2)
Equal to operator.
Definition BuiltinTransports.hpp:79
std::ostream & operator<<(std::ostream &output, BuiltinTransports transports)
Definition BuiltinTransports.hpp:117
SequenceNumber_t operator+(const SequenceNumber_t &seq, const uint32_t inc) noexcept
Add one uint32_t to a SequenceNumber_t.
Definition SequenceNumber.hpp:258
bool operator<=(const SequenceNumber_t &seq1, const SequenceNumber_t &seq2) noexcept
Checks if a SequenceNumber_t is less or equal than other.
Definition SequenceNumber.hpp:218
bool operator!=(const EntityId_t &id1, const EntityId_t &id2)
Guid prefix comparison operator.
Definition EntityId_t.hpp:267
bool operator<(const GUID_t &g1, const GUID_t &g2)
Definition Guid.hpp:192
SequenceNumber_t operator-(const SequenceNumber_t &seq, const uint32_t inc) noexcept
Subtract one uint32_t from a SequenceNumber_t.
Definition SequenceNumber.hpp:236
bool operator>=(const SequenceNumber_t &seq1, const SequenceNumber_t &seq2) noexcept
Checks if a SequenceNumber_t is greater or equal than other.
Definition SequenceNumber.hpp:200
bool operator>(const SequenceNumber_t &seq1, const SequenceNumber_t &seq2) noexcept
Checks if a SequenceNumber_t is greater than other.
Definition SequenceNumber.hpp:164
Structure SequenceNumber_t, different for each change in the same writer.
Definition SequenceNumber.hpp:38
SequenceNumber_t(int32_t hi, uint32_t lo) noexcept
Definition SequenceNumber.hpp:55
int32_t high
Definition SequenceNumber.hpp:40
uint32_t low
Definition SequenceNumber.hpp:42
SequenceNumber_t(uint64_t u) noexcept
Definition SequenceNumber.hpp:66
static SequenceNumber_t unknown() noexcept
Definition SequenceNumber.hpp:123
uint64_t to64long() const noexcept
Convert the number to 64 bit.
Definition SequenceNumber.hpp:76
SequenceNumber_t() noexcept
Default constructor.
Definition SequenceNumber.hpp:45
Definition SequenceNumber.hpp:354
uint32_t operator()(const SequenceNumber_t &a, const SequenceNumber_t &b) const noexcept
Definition SequenceNumber.hpp:355
Defines the STL hash function for type SequenceNumber_t.
Definition SequenceNumber.hpp:344
std::size_t operator()(const SequenceNumber_t &sequence_number) const noexcept
Definition SequenceNumber.hpp:345