00001 /*************************************************************************** 00002 * SpikeStream Application * 00003 * Copyright (C) 2007 by David Gamez * 00004 * david@davidgamez.eu * 00005 * Version 0.1 * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 00023 #ifndef DATABASEMANAGER_H 00024 #define DATABASEMANAGER_H 00025 00026 //SpikeStream includes 00027 #include "DBInterface.h" 00028 #include "BusyDialog.h" 00029 00030 //Qt includes 00031 #include <qdialog.h> 00032 #include <qprocess.h> 00033 #include <qstring.h> 00034 #include <qtable.h> 00035 00036 //Other includes 00037 #include <stack> 00038 00039 00040 //------------------------ Database Manager ------------------------------- 00041 /*! Provides an interface that allows the user to select which databases to 00042 save or load and carries out this saving and loading. */ 00043 //------------------------------------------------------------------------- 00044 00045 class DatabaseManager : public QDialog { 00046 Q_OBJECT 00047 00048 public: 00049 DatabaseManager(QWidget* parent, QString flNme, bool saveDB, DBInterface* netDBInter, DBInterface* archDBInter, DBInterface* pattDBInter, DBInterface* devDBInter); 00050 ~DatabaseManager(); 00051 00052 00053 private slots: 00054 void cancelButtonPressed(); 00055 void okButtonPressed(); 00056 void processExited(); 00057 void readFromStderr(); 00058 void readFromStdout(); 00059 00060 00061 private: 00062 //========================= VARIABLES=============================== 00063 //Database handling classes 00064 DBInterface* netDBInterface; 00065 DBInterface* archDBInterface; 00066 DBInterface* pattDBInterface; 00067 DBInterface* devDBInterface; 00068 00069 /*! Are we saving or loading the database.*/ 00070 bool saveMode; 00071 00072 /*! Set to true when the script is running to list the databases.*/ 00073 bool listingDatabases; 00074 00075 /*! Set to true when the script is running to save the databases.*/ 00076 bool savingDatabase; 00077 00078 /*! Set to true when the script is running to load the databases.*/ 00079 bool loadingDatabase; 00080 00081 //Record which colums have which information 00082 unsigned int nameCol; 00083 unsigned int hostCol; 00084 unsigned int selectionCol; 00085 00086 //Record which databases are on each row 00087 int netDBRow; 00088 int archDBRow; 00089 int pattDBRow; 00090 int devDBRow; 00091 00092 //Qt widgets 00093 QTable* dbTable; 00094 00095 /*! Name of the file to save or load. Should be with an extension.*/ 00096 QString fileName; 00097 00098 /*! File name with extension removed. The extension should be added 00099 back by script.*/ 00100 QString fileNameNoExtension; 00101 00102 /*! The process that executes the script.*/ 00103 QProcess* process; 00104 00105 /*! Holds references to all of the databases that need to be saved.*/ 00106 stack<DBInterface*> dbStack; 00107 00108 /*! Dialog to inform user that it is busy.*/ 00109 BusyDialog* busyDialog; 00110 00111 /*! Records whether the script has started outputing information about 00112 the files. */ 00113 bool storeList; 00114 00115 /*! List of databases that can be loaded from the file.*/ 00116 QStringList loadDBList; 00117 00118 00119 //========================== METHODS =============================== 00120 /*! Declare copy constructor private so it cannot be used inadvertently.*/ 00121 DatabaseManager (const DatabaseManager&); 00122 00123 /*! Declare assignment private so it cannot be used inadvertently.*/ 00124 DatabaseManager operator = (const DatabaseManager&); 00125 00126 int addDatabaseToTable(DBInterface* dbInter); 00127 void fillLoadTable(); 00128 void getAvailableDatabases(); 00129 void loadDatabase(DBInterface* dbInter); 00130 void saveDatabase(DBInterface* dbInter, bool compress); 00131 00132 }; 00133 00134 00135 #endif//DATABASEMANAGER_H 00136
1.4.4