Line data Source code
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 : /****************************************************************************/
14 : /// @file SUMORouteLoaderControl.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Sascha Krieg
17 : /// @author Michael Behrisch
18 : /// @author Jakob Erdmann
19 : /// @date Wed, 06 Nov 2002
20 : ///
21 : // Class responsible for loading of routes from some files
22 : /****************************************************************************/
23 : #pragma once
24 : #include <config.h>
25 :
26 : #include <vector>
27 :
28 :
29 : // ===========================================================================
30 : // class declarations
31 : // ===========================================================================
32 : class SUMORouteLoader;
33 :
34 : // ===========================================================================
35 : // class definitions
36 : // ===========================================================================
37 : /**
38 : * @class SUMORouteLoaderControl
39 : *
40 : * SUMORouteLoaderControl
41 : * This controls is initialised with the list of route loaders and uses them
42 : * to load routes step wise.
43 : * The parameter myInAdvanceStepNo holds the number of time steps to read the
44 : * routes in forward. If it is 0 (default), all routes will be read at once.
45 : */
46 : class SUMORouteLoaderControl {
47 : public:
48 : /// @brief constructor
49 : SUMORouteLoaderControl(SUMOTime inAdvanceStepNo);
50 :
51 : /// @brief destructor
52 : ~SUMORouteLoaderControl();
53 :
54 : /// @brief add another loader
55 : void add(SUMORouteLoader* loader);
56 :
57 : /// @brief loads the next routes up to and including the given time step
58 : void loadNext(SUMOTime step);
59 :
60 : /// @brief returns the timestamp of the first loaded vehicle or flow
61 : SUMOTime getFirstLoadTime() const {
62 5627 : return myFirstLoadTime;
63 : }
64 :
65 : /// @brief returns whether loading is completed
66 : bool haveAllLoaded() const {
67 2463 : return myAllLoaded;
68 : }
69 :
70 : /// @brief return a route loader
71 : SUMORouteLoader* getFirstLoader() const;
72 :
73 : SUMOTime getCurrentLoadTime() const {
74 545 : return myCurrentLoadTime;
75 : }
76 :
77 : void setCurrentLoadTime(SUMOTime time) {
78 671 : myCurrentLoadTime = time;
79 : }
80 :
81 : private:
82 : /// @brief the first time step for which vehicles were loaded
83 : SUMOTime myFirstLoadTime;
84 :
85 : /// @brief the time step up to which vehicles were loaded
86 : SUMOTime myCurrentLoadTime;
87 :
88 : /// @brief the number of routes to read in forward
89 : const SUMOTime myInAdvanceStepNo;
90 :
91 : /// @brief the list of route loaders
92 : std::vector<SUMORouteLoader*> myRouteLoaders;
93 :
94 : /// @brief information whether all routes shall be loaded and whether they were loaded
95 : bool myLoadAll, myAllLoaded;
96 :
97 : private:
98 : /// @brief Invalidated copy constructor
99 : SUMORouteLoaderControl(const SUMORouteLoaderControl& src);
100 :
101 : /// @brief Invalidated assignment operator
102 : SUMORouteLoaderControl& operator=(const SUMORouteLoaderControl& src);
103 : };
|