Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMORouteLoaderControl.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-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/****************************************************************************/
20// Class responsible for loading of routes from some files
21/****************************************************************************/
22#include <config.h>
23
24#include <vector>
26#include "SUMORouteLoader.h"
28
29
30// ===========================================================================
31// method definitions
32// ===========================================================================
34 myFirstLoadTime(SUMOTime_MAX),
35 myCurrentLoadTime(-SUMOTime_MAX),
36 myInAdvanceStepNo(inAdvanceStepNo),
37 myRouteLoaders(),
38 myLoadAll(inAdvanceStepNo <= 0),
39 myAllLoaded(false) {
40}
41
42
44 for (std::vector<SUMORouteLoader*>::iterator i = myRouteLoaders.begin();
45 i != myRouteLoaders.end(); ++i) {
46 delete (*i);
47 }
48}
49
50
51void
53 myRouteLoaders.push_back(loader);
54}
55
56
57void
59 // check whether new vehicles shall be loaded
60 // return if not
61 if (myAllLoaded) {
62 return;
63 }
64 if (myCurrentLoadTime > step) {
65 return;
66 }
69 // load all routes for the specified time period
70 bool furtherAvailable = false;
71 for (SUMORouteLoader* loader : myRouteLoaders) {
72 myCurrentLoadTime = MIN2(myCurrentLoadTime, loader->loadUntil(loadMaxTime));
73 if (loader->getFirstDepart() != -1) {
74 myFirstLoadTime = MIN2(myFirstLoadTime, loader->getFirstDepart());
75 }
76 furtherAvailable |= loader->moreAvailable();
77 }
80 }
81 myAllLoaded = !furtherAvailable;
82}
83
84
85/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define SUMOTime_MAX
Definition SUMOTime.h:34
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
SUMOTime myCurrentLoadTime
the time step up to which vehicles were loaded
bool myLoadAll
information whether all routes shall be loaded and whether they were loaded
std::vector< SUMORouteLoader * > myRouteLoaders
the list of route loaders
const SUMOTime myInAdvanceStepNo
the number of routes to read in forward
SUMOTime myFirstLoadTime
the first time step for which vehicles were loaded
void loadNext(SUMOTime step)
loads the next routes up to and including the given time step
void add(SUMORouteLoader *loader)
add another loader
SUMORouteLoaderControl(SUMOTime inAdvanceStepNo)
constructor