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 NETWORKMODELXMLHANDLER_H 00024 #define NETWORKMODELXMLHANDLER_H 00025 00026 //SpikeStream includes 00027 #include "MonitorArea.h" 00028 00029 //Qt includes 00030 #include <qxml.h> 00031 #include <qstring.h> 00032 00033 //Other includes 00034 #include <vector> 00035 00036 00037 //---------------------- Network Model XML Handler ------------------------- 00038 /*! Used during SAX2 parsing of XML file representing the model of a neural 00039 network. Each neuron group that is read in is used to add a new window 00040 to the MonitorArea. */ 00041 //-------------------------------------------------------------------------- 00042 00043 class NetworkModelXmlHandler : public QXmlDefaultHandler { 00044 00045 public: 00046 NetworkModelXmlHandler(MonitorArea*); 00047 ~NetworkModelXmlHandler(); 00048 QString getNetworkModelString(); 00049 vector<NeuronGroup*> getNeuronGrpVector(); 00050 bool getParseError(); 00051 QString getParseErrorString(); 00052 00053 protected: 00054 //Inherited parsing methods 00055 bool characters ( const QString & ch ); 00056 bool endElement( const QString&, const QString&, const QString& ); 00057 bool startDocument(); 00058 bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& ); 00059 00060 //Inherited error handling methods 00061 bool error ( const QXmlParseException & exception ); 00062 QString errorString (); 00063 bool fatalError ( const QXmlParseException & exception ); 00064 bool warning ( const QXmlParseException & exception ); 00065 00066 00067 private: 00068 //========================== VARIABLES ================================ 00069 /*! Stores the current element.*/ 00070 QString currentElement; 00071 00072 /*! Reference to the monitor area that this class is loading.*/ 00073 MonitorArea *monitorArea; 00074 00075 /*! NeuronGroup used to hold information about the current neuron group 00076 as it is parsed. */ 00077 NeuronGroup *neuronGrp; 00078 00079 /*! Store the neuron groups in the network model to enable statistics 00080 to be set up.*/ 00081 vector<NeuronGroup*> neurGrpVect; 00082 00083 /*! Records whether there has been an error during parsing. */ 00084 bool parseError; 00085 00086 /*! Error messages generated during parsing. */ 00087 QString parseErrorString; 00088 00089 /*! A nicely formatted version of the network model string that is 00090 being parsed. This is useful for setting the paramters for the 00091 statistics.*/ 00092 QString networkModelString; 00093 00094 00095 //=========================== METHODS ================================= 00096 /*! Declare copy constructor private so it cannot be used inadvertently.*/ 00097 NetworkModelXmlHandler (const NetworkModelXmlHandler&); 00098 00099 /*! Declare assignment private so it cannot be used inadvertently.*/ 00100 NetworkModelXmlHandler operator = (const NetworkModelXmlHandler&); 00101 00102 }; 00103 00104 00105 #endif //NETWORKMODELXMLHANDLER_H 00106 00107
1.4.4