Changeset 233 in tmcsimulator for branches/FEPSimulator/HighwaysParser.cpp


Ignore:
Timestamp:
11/13/2017 06:07:07 PM (8 years ago)
Author:
jtorres
Message:

FEPSim: finalized comments, added to both header and source files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FEPSimulator/HighwaysParser.cpp

    r218 r233  
    11/*  
    2  * File:   HighwaysParser.cpp 
    3  * Author: jtorres 
     2 * File:   HighwaysParser.h 
    43 *  
    5  * Created on October 28, 2017, 7:23 PM 
     4 * The HighwaysParser class takes in a character buffer and parses it into a  
     5 * vector of FEP_LINEs and a vector of STATIONS. The buffer is sent in via the 
     6 * constructor and the FEP_LINE and STATION vectors are accessible via public 
     7 * members. 
     8 *  
     9 * @author John A. Torres 
    610 */ 
    711 
    812#include "HighwaysParser.h" 
    9      /* 43                   // "number of lines" 
    10      * 32 0 13              // "line id" "count num" "number of stations" 
    11      * 1210831 1 5 S 0.9 8  // "station id" "drop num" "route num"... 
    12      *                      //      ..."direction" "postmile" "number of loops" 
    13      * 1210832  0.0 0       // "loop id" "occ" "vol" 
    14      * 1210833  0.0 0       // .. 
    15      * 1210834  0.0 0       // .. 
    16      * 1210835  0.0 0       // .. 
    17      * 1210836  0.0 0       // .. 
    18      * 1210837  0.0 0       // .. 
    19      * 1210838  0.0 0       // .. 
    20      * 1210839  0.0 0       // .. 
    21       * */ 
     13 
     14// The public stations member, containing the parsed vector of STATIONS 
    2215HighwaysParser::HighwaysParser(char * hwyData) { 
    2316    parseLines(hwyData); 
    2417} 
    2518 
     19// Frees all allocated memory in the class 
    2620HighwaysParser::~HighwaysParser() { 
    2721    // deallocate FEPLines 
     
    4842} 
    4943 
     44/** 
     45 * Parses the buffer into FEP_LINE and STATION vectors. 
     46 *  
     47 * @param highwaysData buffer 
     48 */ 
    5049void HighwaysParser::parseLines(char * hwyData) 
    5150{ 
     51    // convert buffer to cpp string type 
    5252    string highwaysData = hwyData; 
     53    // create buffer stream 
    5354    istringstream highwaysStream(highwaysData); 
     55    // get the number of FEPLines 
    5456    string currLine; 
    5557    getline(highwaysStream, currLine); 
    5658    int numLines; 
    5759    sscanf(currLine.c_str(), "%d", &numLines); 
     60     
     61    // declare variables used in parsing lines and stations 
    5862    int lineNum = 0; 
    5963    long lds = 0; 
     
    7276    int vol = 0; 
    7377 
     78    // for each line 
    7479    for(int lineIndex = 0; lineIndex < numLines; lineIndex++) 
    7580    { 
     
    8792        newLine->schedleSeq = schedleSeq; 
    8893         
     94        // for each station 
    8995        for(int stationIndex = 0; stationIndex < numStations; stationIndex++) 
    9096        { 
     
    104110            newStation->MlTotVol = 0; 
    105111            newStation->OppTotVol = 0; 
    106              
     112            // for each loop 
    107113            for(int loopIndex = 0; loopIndex < numLoops; loopIndex++) 
    108114            { 
     
    121127            newStation->dataPack = DataPacker::packData(newStation); 
    122128             
     129            // add new station to stations vector 
    123130            this->stations.push_back(newStation); 
    124131        } 
     132        // add new line to lines vector 
    125133        this->lines.push_back(newLine); 
    126134    } 
Note: See TracChangeset for help on using the changeset viewer.