/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file SUMORouteLoader.cpp14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Wed, 6 Nov 200217///18// A class that performs the loading of routes19/****************************************************************************/20#include <config.h>2122#include <utils/xml/SUMOSAXReader.h>23#include <utils/xml/XMLSubSys.h>24#include "SUMORouteHandler.h"25#include "SUMORouteLoader.h"262728// ===========================================================================29// method definitions30// ===========================================================================31SUMORouteLoader::SUMORouteLoader(SUMORouteHandler* handler)32: myParser(nullptr), myMoreAvailable(true), myHandler(handler) {33myParser = XMLSubSys::getSAXReader(*myHandler, false, true);34if (!myParser->parseFirst(myHandler->getFileName())) {35throw ProcessError(TLF("Can not read XML-file '%'.", myHandler->getFileName()));36}37}383940SUMORouteLoader::~SUMORouteLoader() {41delete myParser;42delete myHandler;43}444546SUMOTime47SUMORouteLoader::loadUntil(SUMOTime time) {48// read only when further data is available, no error occurred49// and vehicles may be found in the between the departure time of50// the last read vehicle and the time to read until51if (!myMoreAvailable) {52return SUMOTime_MAX;53}54// read vehicles until specified time or the period to read vehicles55// until is reached56while (myHandler->getLastDepart() <= time) {57if (!myParser->parseNext()) {58// no data available anymore59myMoreAvailable = false;60return SUMOTime_MAX;61}62}63return myHandler->getLastDepart();64}656667bool68SUMORouteLoader::moreAvailable() const {69return myMoreAvailable;70}717273SUMOTime74SUMORouteLoader::getFirstDepart() const {75return myHandler->getFirstDepart();76}777879/****************************************************************************/808182