Changeset 86 in tmcsimulator for branches/FEPSimulator/NetworkReader.cpp


Ignore:
Timestamp:
10/09/2017 11:58:19 PM (9 years ago)
Author:
jtorres
Message:

branches/FEPSimulator: updated and improved comments, added Main.cpp which creates the FEPSimulator, minor project configurations (runtime command line arguments / tinyxml.a libosxtinyxml.a)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FEPSimulator/NetworkReader.cpp

    r84 r86  
    11#include "NetworkReader.h" 
    22 
    3 /** 
    4  * Constructor 
    5  * @param networkFileName input xml file 
    6  */ 
    73NetworkReader::NetworkReader(const char * xml) { 
    84    ldsIndex = 0; 
     
    117 
    128LOOP * NetworkReader::parseLoop(TiXmlElement * loopElem) { 
    13         LOOP *loop = new LOOP; 
     9    LOOP *loop = new LOOP; 
    1410 
    15         TiXmlElement *subLoopElem = loopElem->FirstChildElement(); 
    16         loop->loopID = atoi(subLoopElem->GetText()); 
    17         subLoopElem = subLoopElem->NextSiblingElement(); 
    18         loop->loop_loc = (char *) subLoopElem->GetText(); 
    19         subLoopElem = subLoopElem->NextSiblingElement(); 
    20         loop->vol = atoi(subLoopElem->GetText()); 
    21         subLoopElem = subLoopElem->NextSiblingElement(); 
    22         loop->occ = atof(subLoopElem->GetText()); 
    23         subLoopElem = subLoopElem->NextSiblingElement(); 
    24         loop->spd = atof(subLoopElem->GetText()); 
    25          
    26         return loop; 
     11    TiXmlElement *subLoopElem = loopElem->FirstChildElement(); 
     12    loop->loopID = atoi(subLoopElem->GetText()); 
     13    subLoopElem = subLoopElem->NextSiblingElement(); 
     14    loop->loop_loc = (char *) subLoopElem->GetText(); 
     15    subLoopElem = subLoopElem->NextSiblingElement(); 
     16    loop->vol = atoi(subLoopElem->GetText()); 
     17    subLoopElem = subLoopElem->NextSiblingElement(); 
     18    loop->occ = atof(subLoopElem->GetText()); 
     19    subLoopElem = subLoopElem->NextSiblingElement(); 
     20    loop->spd = atof(subLoopElem->GetText()); 
     21 
     22    return loop; 
    2723} 
    2824 
    29 /** 
    30  * Parses a station xml element into an "STATION" 
    31  *  
    32  * @param stationElem the station xml element 
    33  * @param the parent line 
    34  * @return the new station 
    35  */ 
    3625STATION * NetworkReader::parseStation(TiXmlElement *stationElem, FEP_LINE *line) { 
    3726    STATION *station = new STATION; 
    38      
     27 
    3928    TiXmlElement *stationSubElem = stationElem->FirstChildElement(); 
    4029    station->lds = atol(stationSubElem->GetText()); 
     
    5645 
    5746    station->pos = 0; // NOT SURE WHY WE NEED THIS? 
    58      
     47 
    5948    // Add loops to station 
    6049    TiXmlElement *loopElem = stationSubElem->NextSiblingElement()->FirstChildElement(); 
     
    6857    cout << station->loops.size() << endl; 
    6958    station->dataPack = DataPacker::packData(station); 
    70      
     59 
    7160    return station; 
    7261} 
    7362 
    74 /** 
    75  * Parses a "Line" xml element into an FEP_LINE 
    76  * @param lineElem the xml element 
    77  * @return FEP_LINE 
    78  */ 
    7963FEP_LINE * NetworkReader::parseLine(TiXmlElement * lineElem) { 
    8064    FEP_LINE *line = new FEP_LINE; 
     
    10488} 
    10589 
    106 /** 
    107  * Loads FEPLines from a specified xml file 
    108  * @param networkFileName the input xml file 
    109  */ 
    11090void NetworkReader::loadLines(const char * xml) { 
    11191    // Load network xml file 
    11292    TiXmlDocument doc; 
    113     doc.Parse((const char*)xml, 0, TIXML_ENCODING_UTF8); 
     93    doc.Parse((const char*) xml, 0, TIXML_ENCODING_UTF8); 
    11494 
    11595    // grab <Network> element 
     
    126106} 
    127107 
    128 /** 
    129  * Getter for lines 
    130  * @return List of FEP_LINES 
    131  */ 
    132108vector<FEP_LINE*> NetworkReader::getLines() { 
    133109 
     
    135111} 
    136112 
    137 /** 
    138  * Getter for stations 
    139  * @return List of STATIONs 
    140  */ 
    141113vector<STATION*> NetworkReader::getStations() { 
    142114 
Note: See TracChangeset for help on using the changeset viewer.