Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/microsim/MSEdgeWeightsStorage.h
185785 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 MSEdgeWeightsStorage.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date 02.11.2009
18
///
19
// A storage for edge travel times and efforts
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <utils/common/ValueTimeLine.h>
25
26
27
// ===========================================================================
28
// class declarations
29
// ===========================================================================
30
class MSEdge;
31
class SUMOVehicle;
32
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
/**
38
* @class MSEdgeWeightsStorage
39
* @brief A storage for edge travel times and efforts
40
*/
41
class MSEdgeWeightsStorage {
42
public:
43
/// @brief Constructor
44
MSEdgeWeightsStorage();
45
46
47
/// @brief Destructor
48
~MSEdgeWeightsStorage();
49
50
51
/** @brief Returns a travel time for an edge and time if stored
52
* @param[in] e The edge for which the travel time shall be retrieved
53
* @param[in] t The time for which the travel time shall be retrieved
54
* @param[in] value The value if the requested edge/time is described
55
* @return Whether the requested edge/time is described
56
*/
57
bool retrieveExistingTravelTime(const MSEdge* const e, const double t, double& value) const;
58
59
60
/** @brief Returns an effort for an edge and time if stored
61
* @param[in] e The edge for which the effort shall be retrieved
62
* @param[in] t The time for which the effort shall be retrieved
63
* @param[in] value The value if the requested edge/time is described
64
* @return Whether the requested edge/time is described
65
*/
66
bool retrieveExistingEffort(const MSEdge* const e, const double t, double& value) const;
67
68
69
/** @brief Adds a travel time information for an edge and a time span
70
* @param[in] e The described edge
71
* @param[in] begin The begin of the described time span
72
* @param[in] end The end of the described time span
73
* @param[in] value The travel time value for this edge and time span
74
*/
75
void addTravelTime(const MSEdge* const e, double begin, double end, double value);
76
77
78
/** @brief Adds an effort information for an edge and a time span
79
* @param[in] e The described edge
80
* @param[in] begin The begin of the described time span
81
* @param[in] end The end of the described time span
82
* @param[in] value Theeffort value for this edge and time span
83
*/
84
void addEffort(const MSEdge* const e, double begin, double end, double value);
85
86
87
/** @brief Removes the travel time information for an edge
88
* @param[in] e The described edge
89
*/
90
void removeTravelTime(const MSEdge* const e);
91
92
93
/** @brief Removes the effort information for an edge
94
* @param[in] e The described edge
95
*/
96
void removeEffort(const MSEdge* const e);
97
98
99
/** @brief Returns the information whether any travel time is known for the given edge
100
* @param[in] e The investigated edge
101
* @return Whether any travel time information about this edge is stored
102
*/
103
bool knowsTravelTime(const MSEdge* const e) const;
104
105
106
/** @brief Returns the information whether any effort is known for the given edge
107
* @param[in] e The investigated edge
108
* @return Whether any travel time information about this edge is stored
109
*/
110
bool knowsEffort(const MSEdge* const e) const;
111
112
113
private:
114
/// @brief A map of edge->time->travel time
115
std::map<const MSEdge*, ValueTimeLine<double> > myTravelTimes;
116
117
/// @brief A map of edge->time->effort
118
std::map<const MSEdge*, ValueTimeLine<double> > myEfforts;
119
120
121
private:
122
/// @brief Invalidated copy constructor.
123
MSEdgeWeightsStorage(const MSEdgeWeightsStorage&);
124
125
/// @brief Invalidated assignment operator.
126
MSEdgeWeightsStorage& operator=(const MSEdgeWeightsStorage&);
127
128
129
};
130
131