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

NetworkDataXmlHandler.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 NETWORKDATAXMLHANDLER_H
00024 #define NETWORKDATAXMLHANDLER_H
00025 
00026 //SpikeStream includes
00027 #include "NetworkMonitor.h"
00028 #include "ArchiveStatistic.h"
00029 
00030 //Qt includes
00031 #include <qxml.h>
00032 #include <qstring.h>
00033 #include <qwidget.h>
00034 
00035 //---------------------- Network Data XML Handler --------------------------
00036 /*! Called during SAX2 parsing to play back an archive. Parses the XML file
00037         and updates the network monitors. */
00038 //--------------------------------------------------------------------------
00039 
00040 class NetworkDataXmlHandler : public QObject, public QXmlDefaultHandler {
00041         Q_OBJECT
00042 
00043         public:
00044                 NetworkDataXmlHandler();
00045                 ~NetworkDataXmlHandler();
00046                 void addArchiveStatistics(ArchiveStatisticsHolder* archStatHold);
00047                 void deleteArchiveStatistics(unsigned int statID);
00048                 bool getParseError();
00049                 QString getParseErrorString();
00050                 void resetStatistics();
00051                 void setNetworkMonitors(map<unsigned int, NetworkMonitor*>);
00052 
00053 
00054         signals:
00055                 void spikeCountChanged(unsigned int neurSpikeCount);
00056                 void spikeTotalChanged(unsigned int neurSpikeTotal);
00057                 void statisticsChanged();
00058 
00059 
00060         protected:
00061                 //Parsing methods inherited from QXmlDefaultHandler
00062                 bool characters ( const QString & ch );
00063         bool endElement( const QString&, const QString&, const QString& );
00064         bool startDocument();
00065         bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& );
00066                 
00067                 //Error handling methods inherited from QXmlDefaultHandler
00068                 bool error ( const QXmlParseException & exception );
00069                 QString errorString();
00070                 bool fatalError ( const QXmlParseException & exception );
00071                 bool warning ( const QXmlParseException & exception );
00072 
00073 
00074         private:
00075                 //============================ VARIABLES =============================
00076                 /*! Holds the number of spikes in the current time step.*/
00077                 unsigned int neurSpikeCount;
00078 
00079                 /*! Holds the total number of spikes since the start of the archive.*/
00080                 unsigned int neurSpikeTotal;
00081 
00082                 /*! Name of the current element.*/
00083                 QString currentElement;
00084 
00085                 /*! Map of the network monitors that will display the archived data.*/
00086                 map<unsigned int, NetworkMonitor*> networkMonitorMap;
00087 
00088                 /*! Records the current neuron group that is being unpacked.*/
00089                 unsigned int neuronGrpID;
00090 
00091                 /*! Records whether there has been an error during parsing. */
00092                 bool parseError;
00093 
00094                 /*! Error messages generated during parsing. */
00095                 QString parseErrorString;
00096 
00097                 /*! Holds the neuron ids firing at each time step for the gathering of 
00098                         statistics.*/
00099                 dense_hash_map<unsigned int, bool, hash<unsigned int> > neuronIDHashMap;
00100 
00101                 /*! Holds all of the statistics that are monitoring whole neuron
00102                         groups. The key is the neuron group id*/
00103                 map<unsigned int, vector<ArchiveStatistic*> > neuronGrpStatsMap;
00104 
00105                 /*! Holds all of the statistics that are monitoring one or a number
00106                         of neuron ids.*/
00107                 vector<ArchiveStatistic*> otherArchStatsVector;
00108 
00109 
00110                 //============================ METHODS ===============================
00111                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00112                 NetworkDataXmlHandler (const NetworkDataXmlHandler&);
00113 
00114                 /*! Declare assignment private so it cannot be used inadvertently.*/
00115                 NetworkDataXmlHandler operator = (const NetworkDataXmlHandler&);
00116 
00117                 void processStatistics();
00118 
00119 };
00120 
00121 
00122 #endif //NETWORKDATAXMLHANDLER_H
00123 
00124 
00125 

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