FEDEM Solver  R8.0
Source code of the dynamics solver
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
FFaCheckSum Class Reference

Class for holding and calculation of checksum value of objects. More...

#include <FFaCheckSum.H>

Public Member Functions

 FFaCheckSum ()
 The default constructor initializes crc32_table. More...
 
 FFaCheckSum (const FFaCheckSum &)=delete
 The default copy constructor is deleted. More...
 
 ~FFaCheckSum ()
 The destructor deletes the heap-allocated member crc32_table. More...
 
FFaCheckSum & operator= (const FFaCheckSum &cs)
 Assignment operator. More...
 
bool operator== (const FFaCheckSum &cs) const
 Equality operator,. More...
 
void reset ()
 Initializes checksum and addval. More...
 
unsigned int getCurrent () const
 Returns the current checksum value. More...
 
void add (const std::string &e)
 Adds the checksum of a std::string value to checksum. More...
 
void add (char e)
 Adds the checksum of a char value to checksum. More...
 
void add (unsigned char e)
 Adds the checksum of an unsigned char value to checksum. More...
 
void add (short int e)
 Adds the checksum of a short int value to checksum. More...
 
void add (unsigned short int e)
 Adds the checksum of an unsigned short int value to checksum. More...
 
void add (int e)
 Adds the checksum of an int value to checksum. More...
 
void add (unsigned int e)
 Adds the checksum of an unsigned int value to checksum. More...
 
void add (float e)
 Adds the checksum of a float value to checksum. More...
 
void add (double e, int precision=0)
 Adds the checksum of a double value to checksum. More...
 
void add (const FaVec3 &e, int precision=0)
 Adds the checksum of a FaVec3 value to checksum. More...
 
template<class T >
void add (const std::vector< T > &v)
 Adds the checksum of a std::vector value to checksum. More...
 

Private Member Functions

unsigned int doCRC (unsigned int data)
 Calculates the checksum value of a variable casted to unsigned int. More...
 

Private Attributes

unsigned int * crc32_table
 32-bit Cyclic Redundancy Check hashing values More...
 
unsigned int checksum
 Current checksum value. More...
 
unsigned int addval
 Incremented and added to data on each doCRC() call. More...
 
bool isBigEndian
 Determines the Endianness of the computer. More...
 

Friends

std::ostream & operator<< (std::ostream &s, const FFaCheckSum &cs)
 Printing operator. More...
 
std::istream & operator>> (std::istream &s, FFaCheckSum &cs)
 Reading operator. More...
 

Detailed Description

Class for holding and calculation of checksum value of objects.

The checksum calculation is based on a CRC32 (32-bit Cyclic Redundancy Check) algorithm.

Constructor & Destructor Documentation

◆ FFaCheckSum() [1/2]

FFaCheckSum::FFaCheckSum ( )

The default constructor initializes crc32_table.

◆ FFaCheckSum() [2/2]

FFaCheckSum::FFaCheckSum ( const FFaCheckSum &  )
delete

The default copy constructor is deleted.

◆ ~FFaCheckSum()

FFaCheckSum::~FFaCheckSum ( )
inline

The destructor deletes the heap-allocated member crc32_table.

Member Function Documentation

◆ add() [1/11]

void FFaCheckSum::add ( char  e)
inline

Adds the checksum of a char value to checksum.

◆ add() [2/11]

void FFaCheckSum::add ( const FaVec3 &  e,
int  precision = 0 
)

Adds the checksum of a FaVec3 value to checksum.

If precision > 0, each value of e is rounded to precision significant digits before the checksum is calculated. Otherwise, we cast each value to float before calculating the checksum value.

◆ add() [3/11]

void FFaCheckSum::add ( const std::string &  e)
inline

Adds the checksum of a std::string value to checksum.

◆ add() [4/11]

template<class T >
void FFaCheckSum::add ( const std::vector< T > &  v)
inline

Adds the checksum of a std::vector value to checksum.

◆ add() [5/11]

void FFaCheckSum::add ( double  e,
int  precision = 0 
)

Adds the checksum of a double value to checksum.

If precision > 0, the value e is rounded to precision significant digits, and the checksum is calculated from the mantissa and exponent separately and then added together. Otherwise (if precision is zero), the last two bytes (7th and 8th) of the double word e is omitted from the checksum calculation.

◆ add() [6/11]

void FFaCheckSum::add ( float  e)

Adds the checksum of a float value to checksum.

The last (4th) byte of the float word e containing the least significant digits is omitted from the checksum calculation.

◆ add() [7/11]

void FFaCheckSum::add ( int  e)
inline

Adds the checksum of an int value to checksum.

◆ add() [8/11]

void FFaCheckSum::add ( short int  e)
inline

Adds the checksum of a short int value to checksum.

◆ add() [9/11]

void FFaCheckSum::add ( unsigned char  e)
inline

Adds the checksum of an unsigned char value to checksum.

◆ add() [10/11]

void FFaCheckSum::add ( unsigned int  e)
inline

Adds the checksum of an unsigned int value to checksum.

◆ add() [11/11]

void FFaCheckSum::add ( unsigned short int  e)
inline

Adds the checksum of an unsigned short int value to checksum.

◆ doCRC()

unsigned int FFaCheckSum::doCRC ( unsigned int  data)
private

Calculates the checksum value of a variable casted to unsigned int.

◆ getCurrent()

unsigned int FFaCheckSum::getCurrent ( ) const
inline

Returns the current checksum value.

◆ operator=()

FFaCheckSum & FFaCheckSum::operator= ( const FFaCheckSum &  cs)

Assignment operator.

◆ operator==()

bool FFaCheckSum::operator== ( const FFaCheckSum &  cs) const

Equality operator,.

◆ reset()

void FFaCheckSum::reset ( )
inline

Initializes checksum and addval.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const FFaCheckSum &  cs 
)
friend

Printing operator.

◆ operator>>

std::istream& operator>> ( std::istream &  s,
FFaCheckSum &  cs 
)
friend

Reading operator.

Member Data Documentation

◆ addval

unsigned int FFaCheckSum::addval
private

Incremented and added to data on each doCRC() call.

◆ checksum

unsigned int FFaCheckSum::checksum
private

Current checksum value.

◆ crc32_table

unsigned int* FFaCheckSum::crc32_table
private

32-bit Cyclic Redundancy Check hashing values

◆ isBigEndian

bool FFaCheckSum::isBigEndian
private

Determines the Endianness of the computer.


The documentation for this class was generated from the following files: