Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMORouteLoader.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// A class that performs the loading of routes
20/****************************************************************************/
21#include <config.h>
22
24#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(TLF("Can not read XML-file '%'.", myHandler->getFileName()));
38 }
39}
40
41
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
69bool
73
74
79
80
81/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define TLF(string,...)
Definition MsgHandler.h:306
#define SUMOTime_MAX
Definition SUMOTime.h:34
const std::string & getFileName() const
returns the current file name
Parser for routes during their loading.
SUMOTime getLastDepart() const
Returns the last loaded depart time.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
~SUMORouteLoader()
destructor
SUMORouteHandler * myHandler
the used Handler
bool myMoreAvailable
flag with information whether more vehicles should be available
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
SUMOSAXReader * myParser
the used SAXReader
SUMORouteLoader(SUMORouteHandler *handler)
constructor
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
bool parseFirst(std::string systemID)
Start parsing the given file using parseFirst of myXMLReader.
bool parseNext()
Continue a progressive parse started by parseFirst.
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.