| 1 | /** |
|---|
| 2 | * File: NetworkReader.h |
|---|
| 3 | * |
|---|
| 4 | * A NetworkReader reads in data about the traffic network from a specified |
|---|
| 5 | * xml file. |
|---|
| 6 | * |
|---|
| 7 | * A NetworkReader contains two public methods 'getLines' and 'getLoops', |
|---|
| 8 | * which are getters for the list of FEP_LINES, and STATIONS, respectively. |
|---|
| 9 | * |
|---|
| 10 | * Example XML file: |
|---|
| 11 | * <code> |
|---|
| 12 | * <Network> |
|---|
| 13 | * <Line> |
|---|
| 14 | * <Line_Num>5</Line_Num> |
|---|
| 15 | * <Count>20</Count> |
|---|
| 16 | * <Schedule>1</Schedule> |
|---|
| 17 | * <Line_Info>1</Line_Info> |
|---|
| 18 | * <System_Key>1123005673</System_Key> |
|---|
| 19 | * <Global_Seq>1357648</Global_Seq> |
|---|
| 20 | * <Schedule_Seq>26492</Schedule_Seq> |
|---|
| 21 | * <Stations> |
|---|
| 22 | * <Station> |
|---|
| 23 | * <LDS_ID>1205270</LDS_ID> |
|---|
| 24 | * <Line_Num>5</Line_Num> |
|---|
| 25 | * <Drop>19</Drop> |
|---|
| 26 | * <Location>MAIN 1</Location> |
|---|
| 27 | * <Post_Mile>33.0</Post_Mile> |
|---|
| 28 | * <Direction>S</Direction> |
|---|
| 29 | * <Freeway>5</Freeway> |
|---|
| 30 | * <ML_Tot_Vol>0</ML_Tot_Vol> |
|---|
| 31 | * <Opp_Tot_Vol>0</Opp_Tot_Vol> |
|---|
| 32 | * <Loops> |
|---|
| 33 | * <Loop> |
|---|
| 34 | * <Loop_ID>1205272</Loop_ID> |
|---|
| 35 | * <Loop_Location>RAMP_ON</Loop_Location> |
|---|
| 36 | * <Lane_Num>1</Lane_Num> |
|---|
| 37 | * <Vol>0</Vol> |
|---|
| 38 | * <Occ>0</Occ> |
|---|
| 39 | * <Spd>0</Spd> |
|---|
| 40 | * </Loop> |
|---|
| 41 | * ....... |
|---|
| 42 | * </code> |
|---|
| 43 | * |
|---|
| 44 | * @author John A. Torres |
|---|
| 45 | * @verions 9/08/2017 |
|---|
| 46 | */ |
|---|
| 47 | |
|---|
| 48 | // Include guard |
|---|
| 49 | #ifndef __NETWORKREADER_H_INCLUDED__ |
|---|
| 50 | #define __NETWORKREADER_H_INCLUDED__ |
|---|
| 51 | |
|---|
| 52 | // Included dependencies |
|---|
| 53 | #include "network.h" |
|---|
| 54 | #include <vector> |
|---|
| 55 | #include <string.h> |
|---|
| 56 | #include <iostream> |
|---|
| 57 | #include "tinyxml.h" |
|---|
| 58 | #include "DataPacker.h" |
|---|
| 59 | |
|---|
| 60 | class NetworkReader { |
|---|
| 61 | public: |
|---|
| 62 | /** |
|---|
| 63 | * Constructor |
|---|
| 64 | * @param xml Highway Status XML data |
|---|
| 65 | */ |
|---|
| 66 | NetworkReader(const char * xml); |
|---|
| 67 | |
|---|
| 68 | /** |
|---|
| 69 | * Destructor: no cleaning necessary |
|---|
| 70 | */ |
|---|
| 71 | ~NetworkReader(); |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * Returns FEP_LINE list. |
|---|
| 75 | * |
|---|
| 76 | * @return List of FEP_LINES |
|---|
| 77 | */ |
|---|
| 78 | vector<FEP_LINE*> getLines(); |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | * Returns STATIONS list. |
|---|
| 82 | * @return List of STATIONs |
|---|
| 83 | */ |
|---|
| 84 | vector<STATION*> getStations(); |
|---|
| 85 | |
|---|
| 86 | private: |
|---|
| 87 | vector<FEP_LINE*> lines; |
|---|
| 88 | vector<STATION*> stations; |
|---|
| 89 | int ldsIndex; |
|---|
| 90 | |
|---|
| 91 | /** |
|---|
| 92 | * Loads Highway Status data from xml. |
|---|
| 93 | * |
|---|
| 94 | * @param xml Highway Status XML. |
|---|
| 95 | */ |
|---|
| 96 | void loadLines(const char * networkFileName); |
|---|
| 97 | |
|---|
| 98 | /** |
|---|
| 99 | * Parses a single LOOP |
|---|
| 100 | * @param loopElem TinyXML loop elem |
|---|
| 101 | * @return LOOP |
|---|
| 102 | */ |
|---|
| 103 | LOOP * parseLoop(TiXmlElement * loopElem); |
|---|
| 104 | |
|---|
| 105 | /** |
|---|
| 106 | * Parses a single STATION |
|---|
| 107 | * |
|---|
| 108 | * @param TinyXML station element |
|---|
| 109 | * @param the parent FEP_LINE |
|---|
| 110 | * @return STATION |
|---|
| 111 | */ |
|---|
| 112 | STATION * parseStation(TiXmlElement *stationElem, FEP_LINE *line); |
|---|
| 113 | |
|---|
| 114 | /** |
|---|
| 115 | * Parses a single FEP_LINE |
|---|
| 116 | * @param TinyXML line element |
|---|
| 117 | * @return FEP_LINE |
|---|
| 118 | */ |
|---|
| 119 | FEP_LINE * parseLine(TiXmlElement *lineElem); |
|---|
| 120 | }; |
|---|
| 121 | |
|---|
| 122 | #endif |
|---|