Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A class that performs the loading of routes
17 /****************************************************************************/
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
25 #include <utils/xml/XMLSubSys.h>
26 #include "SUMORouteHandler.h"
27 #include "SUMORouteLoader.h"
28 
29 
30 // ===========================================================================
31 // method definitions
32 // ===========================================================================
34  : myParser(nullptr), myMoreAvailable(true), myHandler(handler) {
37  throw ProcessError("Can not read XML-file '" + myHandler->getFileName() + "'.");
38  }
39 }
40 
41 
43  delete myParser;
44  delete myHandler;
45 }
46 
47 
50  // read only when further data is available, no error occurred
51  // and vehicles may be found in the between the departure time of
52  // the last read vehicle and the time to read until
53  if (!myMoreAvailable) {
54  return SUMOTime_MAX;
55  }
56  // read vehicles until specified time or the period to read vehicles
57  // until is reached
58  while (myHandler->getLastDepart() <= time) {
59  if (!myParser->parseNext()) {
60  // no data available anymore
61  myMoreAvailable = false;
62  return SUMOTime_MAX;
63  }
64  }
65  return myHandler->getLastDepart();
66 }
67 
68 
69 bool
71  return myMoreAvailable;
72 }
73 
74 
77  return myHandler->getFirstDepart();
78 }
79 
80 
81 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:35
const std::string & getFileName() const
returns the current file name
bool myMoreAvailable
flag with 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
SUMOTime loadUntil(SUMOTime time)
loads vehicles until a vehicle is read that starts after the specified 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:101
SUMORouteHandler * myHandler
the used Handler
Parser for routes during their loading.
bool parseFirst(std::string systemID)
#define SUMOTime_MAX
Definition: SUMOTime.h:36
SUMOSAXReader * myParser
the used SAXReader
SUMORouteLoader(SUMORouteHandler *handler)
constructor