LCOV - code coverage report
Current view: top level - src/utils/vehicle - SUMORouteLoaderControl.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 31 31
Test Date: 2025-11-13 15:38:19 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-2025 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    SUMORouteLoaderControl.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @date    Wed, 06 Nov 2002
      19              : ///
      20              : // Class responsible for loading of routes from some files
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <vector>
      25              : #include <utils/common/StdDefs.h>
      26              : #include "SUMORouteLoader.h"
      27              : #include "SUMORouteLoaderControl.h"
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // method definitions
      32              : // ===========================================================================
      33        43000 : SUMORouteLoaderControl::SUMORouteLoaderControl(SUMOTime inAdvanceStepNo):
      34        43000 :     myFirstLoadTime(SUMOTime_MAX),
      35        43000 :     myCurrentLoadTime(-SUMOTime_MAX),
      36        43000 :     myInAdvanceStepNo(inAdvanceStepNo),
      37              :     myRouteLoaders(),
      38        43000 :     myLoadAll(inAdvanceStepNo <= 0),
      39        43000 :     myAllLoaded(false) {
      40        43000 : }
      41              : 
      42              : 
      43        42436 : SUMORouteLoaderControl::~SUMORouteLoaderControl() {
      44        42436 :     for (std::vector<SUMORouteLoader*>::iterator i = myRouteLoaders.begin();
      45        76219 :             i != myRouteLoaders.end(); ++i) {
      46        33783 :         delete (*i);
      47              :     }
      48        42436 : }
      49              : 
      50              : 
      51              : void
      52        34207 : SUMORouteLoaderControl::add(SUMORouteLoader* loader) {
      53        34207 :     myRouteLoaders.push_back(loader);
      54        34207 : }
      55              : 
      56              : 
      57              : void
      58     63686341 : SUMORouteLoaderControl::loadNext(SUMOTime step) {
      59              :     // check whether new vehicles shall be loaded
      60              :     //  return if not
      61     63686341 :     if (myAllLoaded) {
      62              :         return;
      63              :     }
      64      2713677 :     if (myCurrentLoadTime > step) {
      65              :         return;
      66              :     }
      67        55553 :     const SUMOTime loadMaxTime = myLoadAll ? SUMOTime_MAX : MAX2(myCurrentLoadTime + myInAdvanceStepNo, step);
      68        55553 :     myCurrentLoadTime = SUMOTime_MAX;
      69              :     // load all routes for the specified time period
      70              :     bool furtherAvailable = false;
      71       102997 :     for (SUMORouteLoader* loader : myRouteLoaders) {
      72        48418 :         myCurrentLoadTime = MIN2(myCurrentLoadTime, loader->loadUntil(loadMaxTime));
      73        47444 :         if (loader->getFirstDepart() != -1) {
      74        45342 :             myFirstLoadTime = MIN2(myFirstLoadTime, loader->getFirstDepart());
      75              :         }
      76        47444 :         furtherAvailable |= loader->moreAvailable();
      77              :     }
      78        54579 :     if (myFirstLoadTime == SUMOTime_MAX) {
      79         9458 :         myFirstLoadTime = 0;
      80              :     }
      81        54579 :     myAllLoaded = !furtherAvailable;
      82              : }
      83              : 
      84              : 
      85              : SUMORouteLoader*
      86           55 : SUMORouteLoaderControl::getFirstLoader() const {
      87           55 :     if (myRouteLoaders.size() > 0) {
      88           55 :         return myRouteLoaders.front();
      89              :     }
      90              :     return nullptr;
      91              : }
      92              : 
      93              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1