16 static U32
min(
const U32 a,
const U32 b) {
17 return (a < b) ? a : b;
29 Checksum(
const U32 value) : m_value(value)
49 this->m_value = checksum.m_value;
56 return this->m_value == checksum.m_value;
62 return not (*
this == checksum);
81 const U32 offsetMod4 = offset % 4;
82 if (offsetMod4 != 0) {
83 const U8 wordLength =
static_cast<U8>(
min(length, 4 - offsetMod4));
84 this->addWordUnaligned(
86 static_cast<U8>(offset + index),
93 for ( ; index + 4 <= length; index += 4) {
94 addWordAligned(&data[index]);
99 const U8 wordLength =
static_cast<U8>(length - index);
100 this->addWordUnaligned(
102 static_cast<U8>(offset + index),
110 addWordAligned(
const U8 *
const word)
112 for (
U8 i = 0; i < 4; ++i) {
113 addByteAtOffset(word[i], i);
125 U8 offset = position % 4;
126 for (
U8 i = 0; i < length; ++i) {
127 addByteAtOffset(word[i], offset);
142 const U32 addend =
static_cast<U32
>(byte) << (8*(3-offset));
143 this->m_value += addend;
uint8_t U8
8-bit unsigned integer
static U32 min(const U32 a, const U32 b)
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol.
Checksum & operator=(const Checksum &checksum)
Assign checksum to this.
U32 getValue() const
Get the checksum value.
~Checksum()
Destroy a Checksum object.
bool operator!=(const Checksum &checksum) const
Compare checksum and this for inequality.
bool operator==(const Checksum &checksum) const
Compare checksum and this for equality.
Checksum()
Construct a fresh Checksum object.
void update(const U8 *const data, const U32 offset, const U32 length)