LCOV - code coverage report
Current view: top level - src/utils/vehicle - SUMORouteLoader.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 95.2 % 21 20
Test Date: 2024-10-24 15:46:30 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2002-2024 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              : /****************************************************************************/
      14              : /// @file    SUMORouteLoader.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @date    Wed, 6 Nov 2002
      18              : ///
      19              : // A class that performs the loading of routes
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : 
      23              : #include <utils/xml/SUMOSAXReader.h>
      24              : #include <utils/xml/XMLSubSys.h>
      25              : #include "SUMORouteHandler.h"
      26              : #include "SUMORouteLoader.h"
      27              : 
      28              : 
      29              : // ===========================================================================
      30              : // method definitions
      31              : // ===========================================================================
      32        44070 : SUMORouteLoader::SUMORouteLoader(SUMORouteHandler* handler)
      33        44070 :     : myParser(nullptr), myMoreAvailable(true), myHandler(handler) {
      34        44070 :     myParser = XMLSubSys::getSAXReader(*myHandler, false, true);
      35       132210 :     if (!myParser->parseFirst(myHandler->getFileName())) {
      36            0 :         throw ProcessError(TLF("Can not read XML-file '%'.", myHandler->getFileName()));
      37              :     }
      38        44070 : }
      39              : 
      40              : 
      41        41163 : SUMORouteLoader::~SUMORouteLoader() {
      42        41163 :     delete myParser;
      43        41163 :     delete myHandler;
      44        41163 : }
      45              : 
      46              : 
      47              : SUMOTime
      48        56409 : SUMORouteLoader::loadUntil(SUMOTime time) {
      49              :     // read only when further data is available, no error occurred
      50              :     //  and vehicles may be found in the between the departure time of
      51              :     //  the last read vehicle and the time to read until
      52        56409 :     if (!myMoreAvailable) {
      53              :         return SUMOTime_MAX;
      54              :     }
      55              :     // read vehicles until specified time or the period to read vehicles
      56              :     //  until is reached
      57      2932596 :     while (myHandler->getLastDepart() <= time) {
      58      2919283 :         if (!myParser->parseNext()) {
      59              :             // no data available anymore
      60        37974 :             myMoreAvailable = false;
      61        37974 :             return SUMOTime_MAX;
      62              :         }
      63              :     }
      64        13313 :     return myHandler->getLastDepart();
      65              : }
      66              : 
      67              : 
      68              : bool
      69        51439 : SUMORouteLoader::moreAvailable() const {
      70        51439 :     return myMoreAvailable;
      71              : }
      72              : 
      73              : 
      74              : SUMOTime
      75        99957 : SUMORouteLoader::getFirstDepart() const {
      76        99957 :     return myHandler->getFirstDepart();
      77              : }
      78              : 
      79              : 
      80              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1