semf
semf::app::Crc Class Referenceabstract

Interface for implementing cyclic redundancy check (CRC). More...

#include <crc.h>

Inheritance diagram for semf::app::Crc:
Inheritance graph
Collaboration diagram for semf::app::Crc:
Collaboration graph

Public Member Functions

virtual ~Crc ()=default
 
virtual void reset ()=0
 Resets internal values to their initial values. More...
 
virtual const uint8_t * accumulate (const uint8_t data[], size_t size)=0
 Computes the CRC of the input data using a combination of the previous CRC value and the new one. More...
 
virtual const uint8_t * calculate (const uint8_t data[], size_t size)=0
 Calculates the CRC of the input data. More...
 
virtual bool isEqual (const uint8_t data[])=0
 Checks if previously calculated CRC is equal to the input value. More...
 
virtual size_t bitSize () const =0
 Returns the size of the CRC in bits. More...
 
virtual size_t byteSize () const =0
 Returns the size of the CRC in bytes. More...
 

Detailed Description

Interface for implementing cyclic redundancy check (CRC).

Definition at line 23 of file crc.h.

Constructor & Destructor Documentation

◆ ~Crc()

virtual semf::app::Crc::~Crc ( )
virtualdefault

Member Function Documentation

◆ accumulate()

virtual const uint8_t * semf::app::Crc::accumulate ( const uint8_t  data[],
size_t  size 
)
pure virtual

Computes the CRC of the input data using a combination of the previous CRC value and the new one.

Note
This function is helpful if the data is not completely stored in the memory and is called up piece by piece from another memory.
Parameters
dataData over which a CRC value will be computed.
sizeSize of the input data.
Returns
Pointer to the calculated CRC value.
See also
reset().

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.

◆ bitSize()

virtual size_t semf::app::Crc::bitSize ( ) const
pure virtual

Returns the size of the CRC in bits.

Returns
Number of bits of the CRC value.

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.

◆ byteSize()

virtual size_t semf::app::Crc::byteSize ( ) const
pure virtual

Returns the size of the CRC in bytes.

Returns
Number of bytes of the CRC value.

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.

◆ calculate()

virtual const uint8_t * semf::app::Crc::calculate ( const uint8_t  data[],
size_t  size 
)
pure virtual

Calculates the CRC of the input data.

Note
This function is helpful if the data is completely stored in the memory, unlike in accumulate() function.
Parameters
dataData over which a CRC value will be computed.
sizeSize of the input data.
Returns
Pointer to the calculated CRC value.

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.

◆ isEqual()

virtual bool semf::app::Crc::isEqual ( const uint8_t  data[])
pure virtual

Checks if previously calculated CRC is equal to the input value.

Parameters
dataCRC value to compare with calculated CRC value.
Returns
true for CRCs are equal, otherwise false.

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.

◆ reset()

virtual void semf::app::Crc::reset ( )
pure virtual

Resets internal values to their initial values.

See also
accumulate().

Implemented in semf::CrcSoftware< T, DEFAULT_POLYNOMIAL, DEFAULT_INITVALUE, DEFAULT_FINALXOR >.