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

ArchiveManager.h

Go to the documentation of this file.
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 ARCHIVEMANAGER_H
00024 #define ARCHIVEMANAGER_H
00025 
00026 //SpikeStream includes
00027 #include "DBInterface.h"
00028 #include "NetworkDataXmlHandler.h"
00029 #include "NetworkMonitor.h"
00030 #include "GlobalVariables.h"
00031 
00032 //Qt includes
00033 #include <qthread.h>
00034 #include <qwidget.h>
00035 #include <qxml.h>
00036 #include <qdatetime.h>
00037 #include <qstring.h>
00038 
00039 
00040 //-------------------------- Archive Manager -------------------------------
00041 /*! Manages the play back of archives that have been recorded.*/
00042 //--------------------------------------------------------------------------
00043 
00044 class ArchiveManager : public QObject, public QThread {
00045         Q_OBJECT
00046 
00047         public: 
00048                 ArchiveManager(DBInterface *archiveDBInterface, QWidget* archiveWidget);
00049                 ~ArchiveManager();
00050                 void addArchiveStatistics(ArchiveStatisticsHolder* newArchStat);
00051                 bool archiveIsLoaded();
00052                 void deleteArchiveStatistics(unsigned int statID);
00053                 bool fastForwardArchive();
00054                 void freezeArchive();
00055                 QString getSimulationStartDateTime();
00056                 static bool isRunning();
00057                 void loadArchive(QString name);
00058                 bool playArchive();
00059                 bool rewindArchive();
00060                 void setFrameRate(double rate);
00061                 void setNetworkMonitors(map<unsigned int, NetworkMonitor*>);
00062                 bool stepArchive();
00063                 bool stopArchive();
00064                 void unfreezeArchive();
00065                 bool unloadArchive();
00066 
00067 
00068         signals:
00069                 void archiveError(const QString& message);
00070                 void stopped();
00071 
00072 
00073         protected:
00074                 //Method inherited from QThread
00075                 void run();
00076         
00077 
00078         private:
00079                 //===================== VARIABLES ===============================
00080                 /*! Reference to database used by archive manager. */
00081                 DBInterface *archiveDBInterface;
00082 
00083                 /*! Query is held open as archive is playing.*/
00084                 mysqlpp::Query *archiveQuery;
00085 
00086                 /*! The connection used for archive queries by this class.*/
00087                 mysqlpp::Connection* dbConnection;
00088 
00089                 /*! Results is held open as archive is playing.*/
00090                 mysqlpp::ResUse *archiveResults;
00091 
00092                 //XML stuff
00093                 QXmlInputSource xmlInput;
00094         QXmlSimpleReader xmlReader;
00095                 NetworkDataXmlHandler *nwDataXmlHandler;
00096         
00097                 /*! Short version of the reference to the main application to enable 
00098                         updating of events. Used during loading. */
00099                 SpikeStreamApplication *spikeStrApp;
00100                 
00101                 /*! Links neuronGrpIDs to network monitors that are running in this process.*/
00102                 map<unsigned int, NetworkMonitor*> networkMonitorMap;
00103 
00104                 /*! Stores the startDateTime for the currently loaded archive. */
00105                 QString archiveStartDateTime;
00106                 
00107                 /*! Set to true to stop the thread running. */
00108                 bool stop;
00109 
00110                 /*! Records whether the archive is currently playing. Static so that it can be accessed by other classes.
00111                         There will only ever be one archive running at a time. */
00112                 static bool archiveRunning;
00113 
00114                 /*! Records whether the archive is in step mode. */
00115                 bool step;
00116 
00117                 /*! Records whether an archive is loaded and therefore can be played.*/
00118                 bool archiveLoaded;
00119 
00120                 /*! Records the last time the network monitors were updated.*/
00121                 QTime updateTime;
00122                 
00123                 /*! The interval in between updates to the network monitors.*/
00124                 int updateInterval_msec;
00125 
00126                 /*! Variable to hold the update interval in step mode.*/
00127                 int originalUpdateInterval_msec;
00128 
00129                 /*! Set to true when there is an error in the archive. Reset when a new
00130                         archive is loaded.*/
00131                 bool archError;
00132                 
00133                 /* Create variables for use in run method here to save 
00134                         redeclaring them */
00135                 QString networkDataString;
00136                 int elapsedTime_msec;
00137                 unsigned int timeStep;
00138 
00139 
00140                 //========================= METHODS ==============================
00141                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00142                 ArchiveManager (const ArchiveManager&);
00143 
00144                 /*! Declare assignment private so it cannot be used inadvertently.*/
00145                 ArchiveManager operator = (const ArchiveManager&);
00146 
00147                 void setTimeStep(unsigned int);
00148 
00149 };
00150 
00151 
00152 #endif //ARCHIVEMANAGER_H
00153 
00154 

Generated on Mon Sep 3 22:29:04 2007 for SpikeStream Application by  doxygen 1.4.4