Main Page | Namespace List | Data Structures | File List | Data Fields | Globals

networkparser.cpp

Go to the documentation of this file.
00001 # include <network.h>
00002 # include <networkparser.h>
00003 
00004 extern Network * network ;
00005 
00006 int currentlayer = -1 ;
00007 
00008 bool NetworkParser::startDocument() {
00009         network->removeAxons();
00010         network->clearLayer(0) ;
00011         network->clearLayer(1) ;
00012         network->clearHiddenLayers() ;
00013     return TRUE;
00014 }
00015 
00016 bool NetworkParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& qAttributes) {
00017     if( qName == "sigmoid" ) {
00018                 network->setK(qAttributes.value(0).toFloat()) ;
00019     }
00020     
00021     if( qName == "layer" ) {
00022                 int id = qAttributes.value(0).toInt() ;
00023                 if( id > network->getnextfreeid() ) network->setnextfreeid(id+1);
00024                 if( id == 0 ) {
00025                         currentlayer = id ;
00026                 } else if( id == 1 ) {
00027                         currentlayer = id ;
00028                 } else {
00029                         currentlayer = id ;
00030                         network->addHiddenLayer( id ) ;
00031                 }
00032         } else if( qName == "neuron" ) {
00033                 network->addNeuron(     currentlayer, 
00034                                                         qAttributes.value(0).toInt(),                   // Neuron ID
00035                                                         qAttributes.value(1).toFloat(),         // X Coordinate
00036                                                         qAttributes.value(2).toFloat() ) ;      // Z Coordinate
00037                 if( qAttributes.value(0).toInt() > network->getnextfreeid() ) 
00038                         network->setnextfreeid(qAttributes.value(0).toInt()+1);
00039         } else if( qName == "axon" ) {
00040                 network->addAxon(       qAttributes.value(0).toInt(),           // Axon ID
00041                                                         qAttributes.value(1).toInt(),           // Neuron In ID
00042                                                         qAttributes.value(2).toInt(), 
00043                                                         qAttributes.value(3).toDouble() ) ;     // Neuron Out ID
00044                 if( qAttributes.value(0).toInt() > network->getnextfreeid() ) 
00045                         network->setnextfreeid(qAttributes.value(0).toInt()+1);
00046         }
00047         
00048     return TRUE ;
00049 }
00050 
00051 bool NetworkParser::endElement( const QString&, const QString&, const QString& /*qName*/ ) {
00052     return TRUE ;
00053 }
00054 
00055 bool NetworkParser::endDocument() {
00056         return TRUE ;
00057 }

Generated on Fri Dec 3 14:57:50 2004 for INN by doxygen 1.3.6