SUMO - Simulation of Urban MObility
SUMORouteLoader.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A class that performs the loading of routes
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
32 #include <utils/xml/XMLSubSys.h>
33 #include "SUMORouteLoader.h"
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  : myParser(0), myMoreAvailable(true), myHandler(handler) {
43  throw ProcessError("Can not read XML-file '" + myHandler->getFileName() + "'.");
44  }
45 }
46 
47 
49  delete myParser;
50  delete myHandler;
51 }
52 
53 
56  // read only when further data is available, no error occured
57  // and vehicles may be found in the between the departure time of
58  // the last read vehicle and the time to read until
59  if (!myMoreAvailable) {
60  return SUMOTime_MAX;
61  }
62  // read vehicles until specified time or the period to read vehicles
63  // until is reached
64  while (myHandler->getLastDepart() <= time) {
65  if (!myParser->parseNext()) {
66  // no data available anymore
67  myMoreAvailable = false;
68  return SUMOTime_MAX;
69  }
70  }
71  return myHandler->getLastDepart();
72 }
73 
74 
75 bool
77  return myMoreAvailable;
78 }
79 
80 
83  return myHandler->getFirstDepart();
84 }
85 
86 
87 /****************************************************************************/
const std::string & getFileName() const
returns the current file name
bool myMoreAvailable
information whether more vehicles should be available
~SUMORouteLoader()
destructor
SUMOTime getLastDepart() const
Returns the last loaded depart time.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
bool moreAvailable() const
returns the information whether new data is available
#define SUMOTime_MAX
Definition: TraCIDefs.h:52
SUMOTime loadUntil(SUMOTime time)
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler)
Builds a reader and assigns the handler to it.
Definition: XMLSubSys.cpp:97
SUMORouteHandler * myHandler
the used Handler
Parser for routes during their loading.
bool parseFirst(std::string systemID)
SUMOSAXReader * myParser
the used SAXReader
long long int SUMOTime
Definition: TraCIDefs.h:51
SUMORouteLoader(SUMORouteHandler *handler)
constructor