Checksum Class Reference

Back to the index.

Public Member Functions | Static Public Member Functions | List of all members
Checksum Class Reference

A checksum accumulator. More...

#include <Checksum.h>

Inheritance diagram for Checksum:
UnitTestable

Public Member Functions

 Checksum ()
 Constructs a zeroed checksum. More...
 
uint64_t Value () const
 Retrieves the value of the checksum, as a uint64_t. More...
 
void Add (uint64_t x)
 Add a uint64_t to the checksum. More...
 
void Add (const string &str)
 Add a string to the checksum. More...
 
bool operator== (const Checksum &other) const
 Compares one Checksum to another for equality. More...
 
bool operator!= (const Checksum &other) const
 Compares one Checksum to another for inequality. More...
 

Static Public Member Functions

static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from UnitTestable
static void RunUnitTests (int &nSucceeded, int &nFailures)
 Runs unit test cases. More...
 

Detailed Description

A checksum accumulator.

The main purpose of this class is as a helper in unit tests, where objects such as trees are hard to compare to each other. A checksum of the first tree can then be compared with a checksum of the second tree.

Note: This is not scientifically correct in any way. It is just something I made up, for unit testing purposes. (2007-12-27)

Definition at line 47 of file Checksum.h.

Constructor & Destructor Documentation

◆ Checksum()

Checksum::Checksum ( )

Constructs a zeroed checksum.

Definition at line 31 of file Checksum.cc.

Member Function Documentation

◆ Add() [1/2]

void Checksum::Add ( const string &  str)

Add a string to the checksum.

Parameters
strThe string to add.

Definition at line 50 of file Checksum.cc.

References Add().

◆ Add() [2/2]

void Checksum::Add ( uint64_t  x)

Add a uint64_t to the checksum.

Parameters
xValue to add.

Definition at line 43 of file Checksum.cc.

Referenced by Add(), and Component::AddChecksum().

◆ operator!=()

bool Checksum::operator!= ( const Checksum &  other) const

Compares one Checksum to another for inequality.

Parameters
otherThe Checksum to compare to.
Returns
false if the checksums match, true otherwise.

Definition at line 66 of file Checksum.cc.

◆ operator==()

bool Checksum::operator== ( const Checksum &  other) const

Compares one Checksum to another for equality.

Parameters
otherThe Checksum to compare to.
Returns
true if the checksums match, false otherwise.

Definition at line 60 of file Checksum.cc.

◆ RunUnitTests()

static void Checksum::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

◆ Value()

uint64_t Checksum::Value ( ) const

Retrieves the value of the checksum, as a uint64_t.

Returns
the checksum value

Definition at line 37 of file Checksum.cc.


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

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17