libxcks
0.1.0.1
|
Calculates a checksum. More...
#include <ckcalculator.hpp>
Public Types | |
enum class | State { Ok = 0 , NoValidAlgoId , OutOfMemory , ReadError , FileNotFound , CantOpenFile , CancelledByUser } |
States that can be returned by the calculate or the check method. More... | |
Public Member Functions | |
ChecksumCalculator (ChecksumCalculatorProgress &progressHandler=defaultChecksumCalculatorProgress, const unsigned int newNbThreads=automatic_thread_number, const size_t newBufferSize=default_buffer_size) | |
Constructor. More... | |
ChecksumCalculator (const ChecksumCalculator &)=delete | |
Deleted copy constructor. More... | |
ChecksumCalculator & | operator= (const ChecksumCalculator &)=delete |
Deleted assignment operator. More... | |
virtual | ~ChecksumCalculator ()=default |
Destructor. More... | |
size_t | getBufferSize () const |
Gets the size of the buffer to use for reading in the input stream. More... | |
size_t | setBufferSize (const size_t newBufSize) |
Sets the size of the buffer to use for reading in the input stream. More... | |
unsigned int | getNbThreads () const |
Returns the number of threads to use to compute checksums. More... | |
unsigned int | setNbThreads (const unsigned int newNbThreads) |
Sets the number of threads to use to compute checksums. More... | |
ChecksumCalculatorProgress & | getChecksumProgress () const |
Gets the progress handler used to show the progression. More... | |
State | calculate (ChecksumValue &sumValue, const ChecksumAlgoId id, std::istream &is) |
Calculates the checksum from the given stream. More... | |
State | calculate (ArrayChecksumValue &sumValues, const ArrayChecksumAlgoId &ids, std::istream &is) |
Calculates the checksums from the given stream. More... | |
Static Public Attributes | |
static constexpr unsigned int | automatic_thread_number = 0u |
System dependent value for number of threads for computing checksums. More... | |
Protected Attributes | |
ChecksumCalculatorProgress & | progress |
The progress handler used to show the progression. More... | |
size_t | bufferSize |
The size of the buffer to use for reading the input stream. More... | |
unsigned int | nbThreads |
Number of threads to compute checksums. More... | |
Static Protected Attributes | |
static DefaultChecksumCalculatorProgress | defaultChecksumCalculatorProgress |
Default progress checksum calculator instance. More... | |
static constexpr size_t | default_buffer_size = 4096u |
Default buffer size for reading streams. More... | |
static constexpr size_t | min_buffer_size = 1u |
Minimal buffer size for reading streams. More... | |
static constexpr size_t | max_buffer_size = 1048576u |
Maximal buffer size for reading streams. More... | |
static constexpr unsigned int | default_thread_number = 2u |
Default number of threads for computing checksums if the number of cores of the system cannot be automatically found. More... | |
static constexpr unsigned int | max_thread_number = 32u |
Maximal value for number of threads for computing checksums. More... | |
Calculates a checksum.
Provides an interface for showing the progression.
Please note that all the pointers passed to this class are not freed, it is the responsibility to the users of this class to free them.
Definition at line 112 of file ckcalculator.hpp.
|
strong |
States that can be returned by the calculate or the check method.
Definition at line 116 of file ckcalculator.hpp.
libxcks::ChecksumCalculator::ChecksumCalculator | ( | ChecksumCalculatorProgress & | progressHandler = defaultChecksumCalculatorProgress , |
const unsigned int | newNbThreads = automatic_thread_number , |
||
const size_t | newBufferSize = default_buffer_size |
||
) |
Constructor.
progressHandler | ChecksumCalculatorProgress instance class to show the progress. |
newNbThreads | The number of threads to use to compute checksums. |
newBufferSize | The size of the buffer to use for reading in the input stream. |
Definition at line 134 of file ckcalculator.cpp.
|
delete |
Deleted copy constructor.
|
virtualdefault |
Destructor.
ChecksumCalculator::State libxcks::ChecksumCalculator::calculate | ( | ArrayChecksumValue & | sumValues, |
const ArrayChecksumAlgoId & | ids, | ||
std::istream & | is | ||
) |
Calculates the checksums from the given stream.
sumValues
is cleared before adding computed values.[out] | sumValues | The calculated values of the checksums from the input stream. |
[in] | ids | The ids of the wanted algorithm of checksums. |
[in,out] | is | Input stream from which the data will be extracted to compute the checksum. The data are extracted until the end of the stream is reached. |
Ok
if the checksum has been successfully calculated. NoValidAlgoId
if no valid id of algorithm of checksum has been provided. ReadError
if a read error has occurred. Cancelled
if the user has cancelled the calculation. Definition at line 243 of file ckcalculator.cpp.
ChecksumCalculator::State libxcks::ChecksumCalculator::calculate | ( | ChecksumValue & | sumValue, |
const ChecksumAlgoId | id, | ||
std::istream & | is | ||
) |
Calculates the checksum from the given stream.
[out] | sumValue | The calculated value of the checksum from the input stream. |
[in] | id | The id of the wanted algorithm of checksums. |
[in,out] | is | Input stream from which the data will be extracted to compute the checksum. The data are extracted until the end of the stream is reached. |
Ok
if the checksum has been successfully calculated. NoValidAlgoId
if no valid id of algorithm of checksum has been provided. ReadError
if a read error has occurred. Cancelled
if the user has cancelled the calculation. Definition at line 225 of file ckcalculator.cpp.
size_t libxcks::ChecksumCalculator::getBufferSize | ( | ) | const |
Gets the size of the buffer to use for reading in the input stream.
Definition at line 148 of file ckcalculator.cpp.
ChecksumCalculatorProgress & libxcks::ChecksumCalculator::getChecksumProgress | ( | ) | const |
Gets the progress handler used to show the progression.
Definition at line 215 of file ckcalculator.cpp.
unsigned int libxcks::ChecksumCalculator::getNbThreads | ( | ) | const |
Returns the number of threads to use to compute checksums.
Definition at line 173 of file ckcalculator.cpp.
|
delete |
Deleted assignment operator.
size_t libxcks::ChecksumCalculator::setBufferSize | ( | const size_t | newBufSize | ) |
Sets the size of the buffer to use for reading in the input stream.
The provided size must be between min_buffer_size
and max_buffer_size
, otherwise, the default value is
used.
newBufSize | The new size of the buffer to use for reading in the input stream. |
Definition at line 158 of file ckcalculator.cpp.
unsigned int libxcks::ChecksumCalculator::setNbThreads | ( | const unsigned int | newNbThreads | ) |
Sets the number of threads to use to compute checksums.
newNbThreads | The new number of threads to use to compute checksums. |
Definition at line 183 of file ckcalculator.cpp.
|
staticconstexpr |
System dependent value for number of threads for computing checksums.
Definition at line 146 of file ckcalculator.hpp.
|
protected |
The size of the buffer to use for reading the input stream.
Definition at line 141 of file ckcalculator.hpp.
|
staticconstexprprotected |
Default buffer size for reading streams.
Definition at line 129 of file ckcalculator.hpp.
|
staticconstexprprotected |
Default number of threads for computing checksums if the number of cores of the system cannot be automatically found.
Definition at line 136 of file ckcalculator.hpp.
|
staticprotected |
Default progress checksum calculator instance.
Definition at line 128 of file ckcalculator.hpp.
|
staticconstexprprotected |
Maximal buffer size for reading streams.
Definition at line 131 of file ckcalculator.hpp.
|
staticconstexprprotected |
Maximal value for number of threads for computing checksums.
Definition at line 138 of file ckcalculator.hpp.
|
staticconstexprprotected |
Minimal buffer size for reading streams.
Definition at line 130 of file ckcalculator.hpp.
|
protected |
Number of threads to compute checksums.
Definition at line 142 of file ckcalculator.hpp.
|
protected |
The progress handler used to show the progression.
Definition at line 140 of file ckcalculator.hpp.