Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ChecksumCalculator Class Reference

Calculates a checksum. More...

#include <checksumutil.hpp>

Inheritance diagram for ChecksumCalculator:

Inheritance graph
[legend]
Collaboration diagram for ChecksumCalculator:

Collaboration graph
[legend]
List of all members.

Public Types

enum  State {
  Ok = 0, Invalid, ReadError, FileNotFound,
  CantOpenFile, CanceledByUser
}
 States that can be returned by the calculate or the check method. More...


Public Member Functions

State calculate (wxInputStream &in, const ArrayChecksum &checksums, wxArrayString &sumValues)
 Calculates the checksums from the given stream.

State calculate (wxInputStream &in, wxString &sumValue)
 Calculates the checksum from the given stream.

State check (wxInputStream &in, const wxString &value)
 Checks the checksum from the given stream.

ChecksumgetChecksum () const
 Gets the checksum's instance use to calculate the checksums.

ChecksumProgressgetChecksumProgress () const
 Gets the progress handler used to show the progression.

ChecksumsetChecksum (Checksum *checksum)
 Sets the checksum's instance use to calculate the checksums.

ChecksumProgresssetChecksumProgress (ChecksumProgress *progressHandler)
 Sets the progress handler used to show the progression.


Protected Member Functions

 ChecksumCalculator (Checksum *checksum, ChecksumProgress *progressHandler=NULL)
 Constructor with a checksum instance to use and an optional progress handler.

 ChecksumCalculator ()
 Default constructor.

size_t getBufferSize () const
 Gets the size of the buffer to use for reading in the input stream.

size_t setBufferSize (const size_t bufSize)
 Sets the size of the buffer to use for reading in the input stream.


Protected Attributes

size_t bufferSize
 The size of the buffer to use for reading in the input stream.

ArrayChecksum checksumCalc
 Checksum's instance use to calculate the checksums.

ChecksumProgressprogress
 The progress handler used to show the progression.


Detailed Description

Calculates a checksum.

Provides an interface for showing the progression.

Don't pass this class by value and don't use the assignment operator on it.

Please note that all the pointers passed to this class are not freed, it is the responsability to the users of this class to free them.

Definition at line 60 of file checksumutil.hpp.


Member Enumeration Documentation

enum ChecksumCalculator::State
 

States that can be returned by the calculate or the check method.

Definition at line 64 of file checksumutil.hpp.

Referenced by calculate(), and check().


Constructor & Destructor Documentation

ChecksumCalculator::ChecksumCalculator  )  [protected]
 

Default constructor.

Definition at line 58 of file checksumutil.cpp.

References checksumCalc, setBufferSize(), and setChecksumProgress().

ChecksumCalculator::ChecksumCalculator Checksum checksum,
ChecksumProgress progressHandler = NULL
[protected]
 

Constructor with a checksum instance to use and an optional progress handler.

Parameters:
checksum Adress of a Checksum instance class to use for calculating the checksums.
progressHandler Adress of a ChecksumProgress instance class to show the progress (could be NULL).

Definition at line 75 of file checksumutil.cpp.

References checksumCalc, setBufferSize(), and setChecksumProgress().


Member Function Documentation

ChecksumCalculator::State ChecksumCalculator::calculate wxInputStream &  in,
const ArrayChecksum &  checksums,
wxArrayString &  sumValues
 

Calculates the checksums from the given stream.

Parameters:
in 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.
checksums Array of checksums to calculate.
sumValues The calculated values of the checksums from the input stream. The array is erased first before adding results. On success ArrayChecksum.GetCount() == sumValues.GetCount(), on failure, sumValues should be empty.
Returns:
  • Ok if the checksum has been successfully calculated.
  • ReadError if a read error has occured.
  • Canceled if the user has canceled the calculation.

Definition at line 208 of file checksumutil.cpp.

References calculate(), getBufferSize(), getChecksumProgress(), State, and ChecksumProgress::update().

ChecksumCalculator::State ChecksumCalculator::calculate wxInputStream &  in,
wxString &  sumValue
 

Calculates the checksum from the given stream.

Parameters:
in 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.
sumValue The calculated value of the checksum from the input stream.
Returns:
  • Ok if the checksum has been successfully calculated.
  • ReadError if a read error has occured.
  • Canceled if the user has canceled the calculation.

Definition at line 180 of file checksumutil.cpp.

References calculate(), checksumCalc, and State.

Referenced by calculate(), and check().

ChecksumCalculator::State ChecksumCalculator::check wxInputStream &  in,
const wxString &  value
 

Checks the checksum from the given stream.

Parameters:
in 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.
value The value of the checksum which will be compared with the value that will be calculated.
Returns:
  • Ok if the checksum has been successfully calculated and if the two sums are equals.
  • Invalid if the checksum has been successfully calculated and if the two sums are not equals.
  • ReadError if a read error has occured.
  • Canceled if the user has canceled the calculation.

Definition at line 294 of file checksumutil.cpp.

References calculate(), check(), and State.

Referenced by check().

size_t ChecksumCalculator::getBufferSize  )  const [protected]
 

Gets the size of the buffer to use for reading in the input stream.

Returns:
The size of buffer to use for reading in the input stream.

Definition at line 91 of file checksumutil.cpp.

References bufferSize.

Referenced by calculate().

Checksum * ChecksumCalculator::getChecksum  )  const
 

Gets the checksum's instance use to calculate the checksums.

Returns:
The checksum's instance use to calculate the checksums.

Definition at line 118 of file checksumutil.cpp.

References checksumCalc.

Referenced by setChecksum().

ChecksumProgress * ChecksumCalculator::getChecksumProgress  )  const
 

Gets the progress handler used to show the progression.

Returns:
The progress handler used to show the progression.

Definition at line 145 of file checksumutil.cpp.

References progress.

Referenced by calculate(), and setChecksumProgress().

size_t ChecksumCalculator::setBufferSize const size_t  bufSize  )  [protected]
 

Sets the size of the buffer to use for reading in the input stream.

Parameters:
bufSize The new size of the buffer to use for reading in the input stream.
Returns:
The old size of the buffer to use for reading in the input stream.

Definition at line 104 of file checksumutil.cpp.

References bufferSize, and setBufferSize().

Referenced by ChecksumCalculator(), and setBufferSize().

Checksum * ChecksumCalculator::setChecksum Checksum checksum  ) 
 

Sets the checksum's instance use to calculate the checksums.

Parameters:
checksum The checksum's instance which will be used to calculate the checksums.
Returns:
The old checksum's instance use to calculate the checksums.

Definition at line 131 of file checksumutil.cpp.

References checksumCalc, getChecksum(), and setChecksum().

Referenced by setChecksum().

ChecksumProgress * ChecksumCalculator::setChecksumProgress ChecksumProgress progressHandler  ) 
 

Sets the progress handler used to show the progression.

Parameters:
progressHandler The new progress handler which wiil be used to show the progression.
Returns:
The old progress handler used to show the progression.

Definition at line 158 of file checksumutil.cpp.

References getChecksumProgress(), progress, and setChecksumProgress().

Referenced by dlgBatchCreation::batchCreation(), ChecksumCalculator(), and setChecksumProgress().


Member Data Documentation

size_t ChecksumCalculator::bufferSize [protected]
 

The size of the buffer to use for reading in the input stream.

Definition at line 77 of file checksumutil.hpp.

Referenced by getBufferSize(), and setBufferSize().

ArrayChecksum ChecksumCalculator::checksumCalc [protected]
 

Checksum's instance use to calculate the checksums.

Definition at line 75 of file checksumutil.hpp.

Referenced by calculate(), ChecksumCalculator(), getChecksum(), and setChecksum().

ChecksumProgress* ChecksumCalculator::progress [protected]
 

The progress handler used to show the progression.

Definition at line 76 of file checksumutil.hpp.

Referenced by getChecksumProgress(), and setChecksumProgress().


The documentation for this class was generated from the following files:
Generated on Sun May 30 13:38:02 2004 for wxChecksums by doxygen 1.3.7