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

dlgBatchCreate.hpp

Go to the documentation of this file.
00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file dlgBatchCreate.hpp 00022 * Dialog for creating one checksums' file for each selected file. 00023 */ 00024 00025 #ifndef INC_DLGBATCHCREATE_HPP 00026 #define INC_DLGBATCHCREATE_HPP 00027 00028 //--------------------------------------------------------------------------- 00029 // For compilers that support precompilation, includes "wx.h". 00030 #include <wx/wxprec.h> 00031 00032 #ifdef __BORLANDC__ 00033 #pragma hdrstop 00034 #endif 00035 00036 #ifndef WX_PRECOMP 00037 // Include your minimal set of headers here, or wx.h 00038 #include <wx/wx.h> 00039 #endif 00040 #include <wx/filename.h> 00041 00042 #include "dlgResProg.hpp" 00043 #include "bytedisp.hpp" 00044 #include "checksum.hpp" 00045 #include "sumfile.hpp" 00046 //--------------------------------------------------------------------------- 00047 00048 00049 /** 00050 * Dialog which displays results of multiple files checking. 00051 */ 00052 class dlgBatchCreation : public dlgResultsProgress 00053 { 00054 public: 00055 // Creates a new dialog. 00056 dlgBatchCreation(); 00057 00058 protected: 00059 // Creates a new dialog. 00060 dlgBatchCreation(wxWindow *parent); 00061 00062 public: 00063 // The class descructor. 00064 virtual ~dlgBatchCreation() {} 00065 00066 // Creates and initializes the controls of the dialog. 00067 void createControls(); 00068 00069 protected: 00070 wxStaticText* lblTotal; ///< Current checksum file (number/total). 00071 wxGauge* gauTotal; ///< Current checksum file (gauge). 00072 wxStaticText* lblFile; ///< Current file (bytes read/total). 00073 wxGauge* gauFile; ///< Current file (gauge). 00074 00075 // Processes button Cancel. 00076 void btnCancelClick(wxCommandEvent& event); 00077 00078 DECLARE_EVENT_TABLE() 00079 00080 private: 00081 DECLARE_DYNAMIC_CLASS(dlgBatchCreation) 00082 00083 protected: 00084 unsigned long filesToProcess; ///< Number of files to process. 00085 unsigned long fileProcessed; ///< Number of the current file to be processed. 00086 BytesDisplayer totalBytes; ///< Number of bytes of the current checked file. 00087 BytesDisplayer bytesRead; ///< Number of read bytes in the current checked file. 00088 00089 public: 00090 // Gets the number of files to process. 00091 unsigned long getFilesToProcess() const; 00092 // Sets the number of files to process. 00093 void setFilesToProcess(unsigned long nbTotalFiles); 00094 00095 // Gets the number of the current file to be processed. 00096 unsigned long getFileToBeProcessed() const; 00097 // Sets the number of the file to be processed. 00098 void setFileToBeProcessed(unsigned long nbFiles); 00099 00100 // Gets the number of bytes of the current processed file. 00101 BytesDisplayer getTotalBytes() const; 00102 // Sets the number of bytes of the current processed file. 00103 void setTotalBytes(const BytesDisplayer& bytes); 00104 00105 // Gets the number of bytes read of the current processed file. 00106 BytesDisplayer getReadBytes() const; 00107 // Sets the number of bytes read of the current processed file. 00108 void setReadBytes(const BytesDisplayer& bytes); 00109 00110 protected: 00111 // Update the information of the total of the files to be processed. 00112 void updateTotalFiles(); 00113 00114 // Update the information of the current processed file. 00115 void updateCurrentProcessedFile(); 00116 00117 00118 // Statistics on the files. 00119 class FilesStatistics; 00120 00121 public: 00122 /// Verbosity levels. 00123 enum Verbosity 00124 { 00125 vErrors = 0, 00126 vWarnings, 00127 vNormal, 00128 vTalkative, 00129 00130 Verbosity_Min = vErrors, 00131 Verbosity_Max = vTalkative 00132 }; 00133 00134 class Options; 00135 00136 public: 00137 // Batch creation of checksums' files. 00138 static void batchCreation(const wxArrayString& files, const Options& options, 00139 wxArrayInt ckSumsTypes, wxWindow* parent = NULL); 00140 00141 private: 00142 // Progress updater 00143 class ChecksumProgress; 00144 00145 // Utility functions 00146 // Gets the names of the checksums' files to create. 00147 static wxArrayString getChecksumsFileNames(const wxString& srcFileName, 00148 const dlgBatchCreation::Options& options, 00149 const wxArrayInt& ckSumsTypes); 00150 00151 // Indicates if all the checksums' files exist. 00152 static bool allChecksumsFileNamesExist(const wxString& srcFileName, 00153 const dlgBatchCreation::Options& options, 00154 const wxArrayInt& ckSumsTypes); 00155 00156 // Saves the given sums in checksums files. 00157 static void saveChecksumsInFiles(const wxString& srcFileName, 00158 const dlgBatchCreation::Options& options, 00159 const wxArrayInt& ckSumsTypes, 00160 const ArraySumFile& sumFiles, 00161 const wxArrayString& sums, 00162 dlgBatchCreation::FilesStatistics& fstats, 00163 dlgBatchCreation* dlgPrg); 00164 }; 00165 //--------------------------------------------------------------------------- 00166 00167 00168 /** 00169 * Options for the <CODE>dlgBatchCreation</CODE> class. 00170 */ 00171 class dlgBatchCreation::Options 00172 { 00173 protected: 00174 dlgBatchCreation::Verbosity verbosity; ///< Report's Verbosity. 00175 00176 public: 00177 /** 00178 * If <CODE>true</CODE>, when a checksums' file already exists it is 00179 * overwritten. Otherwise the creation of the checksums' file is skipped. 00180 */ 00181 bool ovrCkFileWhenItExists; 00182 00183 /** 00184 * If <CODE>true</CODE> the name of the checksums' file will be made by 00185 * replacing the extension of the source file with the extension of the type 00186 * of the checksums' file. Otherwise, the name of the checksums' file will be 00187 * made by adding the extension of the type of checksums' file to the name of 00188 * the source file. 00189 */ 00190 bool replaceExtension; 00191 00192 // Facility constructor. 00193 Options(const bool iOvrCkFileWhenItExists = false, const bool iReplaceExtension = true, const dlgBatchCreation::Verbosity iVerbosity = vNormal); 00194 00195 // Gets the report's verbosity. 00196 dlgBatchCreation::Verbosity getVerbosity() const; 00197 00198 // Sets the report's verbosity. 00199 void setVerbosity(const dlgBatchCreation::Verbosity newVerbosity); 00200 }; 00201 //--------------------------------------------------------------------------- 00202 00203 00204 00205 #endif // INC_DLGBATCHCREATE_HPP

Generated on Sun May 30 13:37:44 2004 for wxChecksums by doxygen 1.3.7