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

SumFile Class Reference

A sum file. More...

#include <sumfile.hpp>

Inheritance diagram for SumFile:

Inheritance graph
[legend]
List of all members.

Public Member Functions

long addChecksumData (const ChecksumData &checksumData)
 Adds a checksum data in the file.

virtual ChecksumgetChecksumCalculator () const =0
 Returns an instance of a class that permits to compute the checksum value.

void getChecksumData (const long key, ChecksumData &checksumData) const
 Gets the checksum data of the given key.

ChecksumData getChecksumData (const long key) const
 Returns the checksum data of the given key.

MChecksumData::const_iterator getChecksumDataBegin () const
 Returns an iterator pointing at the first element of the checksums data.

size_t getChecksumDataCount () const
 Returns the number of checksum data in file.

MChecksumData::const_iterator getChecksumDataEnd () const
 Returns an iterator pointing at the one-after-the-last element of the checksums data.

void getChecksumDataKeys (MChecksumDataKeys &keys) const
 Gets all the keys of the checksums data.

wxString getFileName () const
 Gets the name of the checksum file.

virtual wxString getFileType () const =0
 Returns the type of the file.

bool getModified () const
 Indicates whether the file has been modified.

wxPathFormat getPathFormat (const wxFileName &fileName, const wxString &commentChars=wxT(";"), const unsigned int maxLinesToRead=UINT_MAX) const
 Gets the path format that is used in the given file.

virtual bool read (const wxFileName &fileName)=0
 Reads the checksums from a file.

bool removeChecksumData (const long key)
 Removes a checksum data in the file.

virtual void reset ()
 Resets the sum file.

bool setChecksumData (const long key, const ChecksumData &checksumData)
 Sets the checksum data of the given key.

bool setChecksumState (const long key, const ChecksumData::State state)
 Sets the checksum state of the given key.

void setFileName (const wxString &newFileName)
 Sets the name of the checksum file.

void setModified (const bool newModifiedState)
 Sets the "modified" state of the file.

 SumFile ()
 Default constructor.

virtual bool write (const wxFileName &fileName)=0
 Writes the checksums in a file.


Protected Member Functions

void clone (const SumFile &source)
 Clones the source instance in this instance.

MChecksumData::iterator getChecksumDataBeginI ()
 Returns an iterator pointing at the first element of the checksums data.

MChecksumData::iterator getChecksumDataEndI ()
 Returns an iterator pointing at the one-after-the-last element of the checksums data.


Static Protected Member Functions

long getID ()
 Gets a new unique identifier.


Private Member Functions

virtual SumFileoperator= (const SumFile &source)
 Assignment operator.

 SumFile (const SumFile &source)
 Copy constructor.


Private Attributes

MChecksumData checksums
 The checksums that are contained in the file.

wxString fileName
 Name of the checksum file. Empty for none.

bool modified
 Indicates that the file has been modified.


Static Private Attributes

long idGen = 0L
 Value for unique identifiers generation.


Detailed Description

A sum file.

Definition at line 129 of file sumfile.hpp.


Constructor & Destructor Documentation

SumFile::SumFile const SumFile source  )  [private]
 

Copy constructor.

Parameters:
source Source instance.

Definition at line 286 of file sumfile.cpp.

References clone().

SumFile::SumFile  ) 
 

Default constructor.

Definition at line 256 of file sumfile.cpp.

References setModified().


Member Function Documentation

long SumFile::addChecksumData const ChecksumData checksumData  ) 
 

Adds a checksum data in the file.

After setting the checksum data, the state of the file is "modified".

Parameters:
checksumData The value of the checksum data to add.
Returns:
The key of the added checksum data.

Definition at line 509 of file sumfile.cpp.

References addChecksumData(), checksums, getID(), and setModified().

Referenced by addChecksumData(), and ChecksumsListView::addFiles().

void SumFile::clone const SumFile source  )  [protected]
 

Clones the source instance in this instance.

Don't forget to call this method when cloning inherited classes.

Parameters:
source Source instance.

Definition at line 270 of file sumfile.cpp.

References checksums, clone(), and modified.

Referenced by clone(), operator=(), and SumFile().

virtual Checksum* SumFile::getChecksumCalculator  )  const [pure virtual]
 

Returns an instance of a class that permits to compute the checksum value.

The calling function is responsible of the deletion of the instance with the delete operator.

Returns:
An instance of a class that permits to compute the checksum value.

Implemented in MD5File, and SFVFile.

Referenced by ChecksumsListView::addFiles(), ChecksumsListView::check(), dlgMultiCheck::checkChecksumsFiles(), and ChecksumsListView::recompute().

void SumFile::getChecksumData const long  key,
ChecksumData checksumData
const
 

Gets the checksum data of the given key.

Parameters:
key The key whose associated checksum data is to be returned.
checksumData The instance of ChecksumData where the checksum data will be stored. If key doesn't exist, an empty checksum data is given.

Definition at line 441 of file sumfile.cpp.

References checksums, and getChecksumData().

ChecksumData SumFile::getChecksumData const long  key  )  const
 

Returns the checksum data of the given key.

Parameters:
key The key whose associated checksum data is to be returned.
Returns:
The checksum data associated at the given key. If key doesn't exist, an empty checksum data is returned.

Definition at line 423 of file sumfile.cpp.

References getChecksumData().

Referenced by ChecksumsListView::addChecksum(), ChecksumsListView::check(), getChecksumData(), ChecksumsListView::getStates(), ChecksumsListView::recompute(), ChecksumsListView::setChecksum(), ChecksumsListView::setChecksumState(), and SumListCompareFnct().

MChecksumData::const_iterator SumFile::getChecksumDataBegin  )  const
 

Returns an iterator pointing at the first element of the checksums data.

Returns:
An iterator pointing at the first element of the checksums data.

Definition at line 546 of file sumfile.cpp.

References checksums.

Referenced by dlgMultiCheck::checkChecksumsFiles(), ChecksumsListView::isInList(), ChecksumsListView::removeFilesInList(), SFVFile::write(), and MD5File::write().

MChecksumData::iterator SumFile::getChecksumDataBeginI  )  [protected]
 

Returns an iterator pointing at the first element of the checksums data.

For internal use only.

Returns:
An iterator pointing at the first element of the checksums data.

Definition at line 572 of file sumfile.cpp.

References checksums.

Referenced by SFVFile::write(), and MD5File::write().

size_t SumFile::getChecksumDataCount  )  const
 

Returns the number of checksum data in file.

Returns:
The number of checksum data in file.

Definition at line 408 of file sumfile.cpp.

References checksums.

Referenced by dlgMultiCheck::checkChecksumsFiles(), and ChecksumsListView::removeFilesInList().

MChecksumData::const_iterator SumFile::getChecksumDataEnd  )  const
 

Returns an iterator pointing at the one-after-the-last element of the checksums data.

Returns:
An iterator pointing at the one-after-the-last element of the checksums data.

Definition at line 558 of file sumfile.cpp.

References checksums.

Referenced by dlgMultiCheck::checkChecksumsFiles(), ChecksumsListView::isInList(), ChecksumsListView::removeFilesInList(), SFVFile::write(), and MD5File::write().

MChecksumData::iterator SumFile::getChecksumDataEndI  )  [protected]
 

Returns an iterator pointing at the one-after-the-last element of the checksums data.

For internal use only.

Returns:
An iterator pointing at the one-after-the-last element of the checksums data.

Definition at line 586 of file sumfile.cpp.

References checksums.

Referenced by SFVFile::write(), and MD5File::write().

void SumFile::getChecksumDataKeys MChecksumDataKeys &  keys  )  const
 

Gets all the keys of the checksums data.

Parameters:
keys The array that will contain the keys of the checksums data. The array will be erased before storing the keys.

Definition at line 389 of file sumfile.cpp.

References checksums, and getChecksumDataKeys().

Referenced by getChecksumDataKeys(), and ChecksumsListView::setSumFile().

wxString SumFile::getFileName  )  const
 

Gets the name of the checksum file.

Returns:
The name of the checksum file. Empty for none.

Definition at line 338 of file sumfile.cpp.

References fileName.

Referenced by dlgMultiCheck::checkChecksumsFiles(), frmSums::checkFileBeforeClose(), ChecksumsListView::isInList(), frmSums::itmFileOpenRecentClick(), frmSums::itmFileSaveClick(), ChecksumsListView::removeFilesInList(), ChecksumsListView::selectDirectoriesToAdd(), ChecksumsListView::selectFilesToAdd(), ChecksumsListView::setChecksum(), SumListCompareFnct(), and frmSums::updateTitle().

virtual wxString SumFile::getFileType  )  const [pure virtual]
 

Returns the type of the file.

Returns:
The type of the file.

Implemented in MD5File, and SFVFile.

Referenced by frmSums::itmFileSaveAsClick(), and frmSums::updateTitle().

long SumFile::getID  )  [static, protected]
 

Gets a new unique identifier.

Returns:
A new unique identifier.

Definition at line 312 of file sumfile.cpp.

References idGen.

Referenced by addChecksumData().

bool SumFile::getModified  )  const
 

Indicates whether the file has been modified.

Returns:
true if the file has been modified, false otherwise.

Definition at line 364 of file sumfile.cpp.

References modified.

Referenced by frmSums::checkFileBeforeClose(), frmSums::FrameClose(), frmSums::itmFileSaveClick(), and frmSums::updateTitle().

wxPathFormat SumFile::getPathFormat const wxFileName &  fileName,
const wxString &  commentChars = wxT(";"),
const unsigned int  maxLinesToRead = UINT_MAX
const
 

Gets the path format that is used in the given file.

Parameters:
fileName The file name of which we want to know the path format.
commentChars Characters that indicate a line of comments.
maxLinesToRead Number of lines of text to read before determine which path format has been used in fileName.
Returns:
The path format that is used in the given file.

Definition at line 604 of file sumfile.cpp.

References getPathFormat().

Referenced by getPathFormat().

SumFile & SumFile::operator= const SumFile source  )  [private, virtual]
 

Assignment operator.

Parameters:
source Source instance.
Returns:
A reference on the instance.

Definition at line 299 of file sumfile.cpp.

References clone(), and operator=().

Referenced by operator=().

virtual bool SumFile::read const wxFileName &  fileName  )  [pure virtual]
 

Reads the checksums from a file.

After the reading of the file, the state of the file should be unmodified and on success, the checksum file name must be the given one (absolute path).

The paths of the files in the ChecksumData must be relative to the path of fileName.

Parameters:
fileName The file name from which the checksums are read.
Returns:
true if the file has been read successfully, false otherwise.

Implemented in MD5File, and SFVFile.

bool SumFile::removeChecksumData const long  key  ) 
 

Removes a checksum data in the file.

After setting the checksum data, the state of the file is "modified".

Parameters:
key The key of the checksum data to remove.
Returns:
true if the checksum data has been removed successfully, false otherwise.

Definition at line 528 of file sumfile.cpp.

References checksums, modified, and removeChecksumData().

Referenced by removeChecksumData(), and ChecksumsListView::removeSelectedChecksums().

void SumFile::reset  )  [virtual]
 

Resets the sum file.

Clears all the checksums in the file and sets the "modified" state to false.

Definition at line 325 of file sumfile.cpp.

References checksums, and setModified().

Referenced by SFVFile::read(), and MD5File::read().

bool SumFile::setChecksumData const long  key,
const ChecksumData checksumData
 

Sets the checksum data of the given key.

After setting the checksum data, the state of the file is "modified".

Parameters:
key The position of the checksum data.
checksumData The new value for the checksum data.
Returns:
If index is out of bounds, returns false, true otherwise.

Definition at line 462 of file sumfile.cpp.

References checksums, setChecksumData(), and setModified().

Referenced by ChecksumsListView::recompute(), and setChecksumData().

bool SumFile::setChecksumState const long  key,
const ChecksumData::State  state
 

Sets the checksum state of the given key.

After setting the checksum data, the state of the file is unchanged.

Parameters:
key The position of the checksum data.
state The new state of the checksum.
Returns:
If index is out of bounds, returns false, true otherwise.

Definition at line 487 of file sumfile.cpp.

References checksums, and setChecksumState().

Referenced by setChecksumState(), and ChecksumsListView::setChecksumState().

void SumFile::setFileName const wxString &  newFileName  ) 
 

Sets the name of the checksum file.

Parameters:
newFileName Name of the new file name of the checksum file.
Remarks:
Provide an empty string for none.

Definition at line 351 of file sumfile.cpp.

References fileName, and setFileName().

Referenced by frmSums::itmFileNewClick(), and setFileName().

void SumFile::setModified const bool  newModifiedState  ) 
 

Sets the "modified" state of the file.

Parameters:
newModifiedState The new "modified" state.

Definition at line 376 of file sumfile.cpp.

References modified, and setModified().

Referenced by addChecksumData(), frmSums::initializeFromCmdLine(), reset(), setChecksumData(), setModified(), and SumFile().

virtual bool SumFile::write const wxFileName &  fileName  )  [pure virtual]
 

Writes the checksums in a file.

After the writing of the file, the state of the file should be unmodified and the file name must be modified to fileName. The paths of the files in the ChecksumData must be relative to the path of fileName.

Parameters:
fileName The file name in which the checksums are written.
Returns:
true if the checksums have been written successfully, false otherwise.

Implemented in MD5File, and SFVFile.

Referenced by frmSums::initializeFromCmdLine(), and frmSums::saveChecksumFile().


Member Data Documentation

MChecksumData SumFile::checksums [private]
 

The checksums that are contained in the file.

Definition at line 133 of file sumfile.hpp.

Referenced by addChecksumData(), clone(), getChecksumData(), getChecksumDataBegin(), getChecksumDataBeginI(), getChecksumDataCount(), getChecksumDataEnd(), getChecksumDataEndI(), getChecksumDataKeys(), removeChecksumData(), reset(), setChecksumData(), and setChecksumState().

wxString SumFile::fileName [private]
 

Name of the checksum file. Empty for none.

Definition at line 134 of file sumfile.hpp.

Referenced by getFileName(), and setFileName().

long SumFile::idGen = 0L [static, private]
 

Value for unique identifiers generation.

Definition at line 249 of file sumfile.cpp.

Referenced by getID().

bool SumFile::modified [private]
 

Indicates that the file has been modified.

Definition at line 135 of file sumfile.hpp.

Referenced by clone(), getModified(), removeChecksumData(), and setModified().


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