-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
RORoutable.h
201 lines (163 loc) · 6.46 KB
/
RORoutable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2002-2024 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file RORoutable.h
/// @author Michael Behrisch
/// @date Oct 2015
///
// A routable thing such as a vehicle or person
/****************************************************************************/
#pragma once
#include <config.h>
#include <string>
#include <iostream>
#include <utils/common/StdDefs.h>
#include <utils/common/SUMOTime.h>
#include <utils/router/RouterProvider.h>
#include <utils/vehicle/SUMOVehicleParameter.h>
#include <utils/vehicle/SUMOVTypeParameter.h>
// ===========================================================================
// class declarations
// ===========================================================================
class OutputDevice;
class ROEdge;
class ROLane;
class RONode;
class ROVehicle;
typedef std::vector<const ROEdge*> ConstROEdgeVector;
typedef IntermodalRouter<ROEdge, ROLane, RONode, ROVehicle> ROIntermodalRouter;
typedef RouterProvider<ROEdge, ROLane, RONode, ROVehicle> RORouterProvider;
// ===========================================================================
// class definitions
// ===========================================================================
/**
* @class RORoutable
* @brief A routable thing such as a vehicle or person
*/
class RORoutable {
public:
/** @brief Constructor
*
* @param[in] pars Parameter of this routable
* @param[in] type The type of the routable
*/
RORoutable(const SUMOVehicleParameter& pars, const SUMOVTypeParameter* type)
: myParameter(pars), myType(type), myRoutingSuccess(false) {}
/// @brief Destructor
virtual ~RORoutable() {}
/** @brief Returns the definition of the vehicle / person parameter
*
* @return The vehicle / person's parameter
*/
inline const SUMOVehicleParameter& getParameter() const {
return myParameter;
}
/** @brief Returns the type of the routable
*
* @return The routable's type
*
* @todo Why not return a reference?
*/
inline const SUMOVTypeParameter* getType() const {
return myType;
}
/** @brief Returns the id of the routable
*
* @return The id of the routable
*/
inline const std::string& getID() const {
return myParameter.id;
}
/** @brief Returns the time the vehicle starts at, -1 for triggered vehicles
*
* @return The vehicle's depart time
*/
inline SUMOTime getDepart() const {
return myParameter.depart;
}
/// @brief update depart time (for triggered persons)
inline void setDepart(SUMOTime t) {
myParameter.depart = t;
}
inline SUMOVehicleClass getVClass() const {
return getType() != 0 ? getType()->vehicleClass : SVC_IGNORING;
}
/** @brief Returns whether this object is ignoring transient permission
* changes (during routing)
*/
bool ignoreTransientPermissions() const {
return false;
};
/// @brief Returns the vehicle's maximum speed
inline double getMaxSpeed() const {
return MIN2(getType()->maxSpeed,
getType()->desiredMaxSpeed * getType()->speedFactor.getParameter()[0]);
}
virtual const ROEdge* getDepartEdge() const = 0;
inline bool isPublicTransport() const {
return myParameter.line != "";
}
inline bool isPartOfFlow() const {
return myParameter.repetitionNumber >= 0;
}
virtual void computeRoute(const RORouterProvider& provider,
const bool removeLoops, MsgHandler* errorHandler) = 0;
/** @brief Saves the routable including the vehicle type (if it was not saved before).
*
* @param[in] os The routes - output device to store the vehicle's description into
* @param[in] altos The route alternatives - output device to store the vehicle's description into
* @param[in] typeos The types - output device to store the vehicle types into
* @exception IOError If something fails (not yet implemented)
*/
void write(OutputDevice* os, OutputDevice* const altos,
OutputDevice* const typeos, OptionsCont& options) const {
if (os != nullptr) {
if (altos == nullptr && typeos == nullptr) {
saveAsXML(*os, os, false, options);
} else {
saveAsXML(*os, typeos, false, options);
}
}
if (altos != nullptr) {
saveAsXML(*altos, typeos, true, options);
}
}
inline bool getRoutingSuccess() const {
return myRoutingSuccess;
}
protected:
/** @brief Saves the complete routable description.
*
* Saves the routable itself including the route and stops.
*
* @param[in] os The routes or alternatives output device to store the routable's description into
* @param[in] typeos The types - output device to store additional types into
* @param[in] asAlternatives Whether the route shall be saved as route alternatives
* @param[in] options to find out about defaults and whether exit times for the edges shall be written
* @exception IOError If something fails (not yet implemented)
*/
virtual void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const = 0;
private:
/// @brief The vehicle's parameter
SUMOVehicleParameter myParameter;
/// @brief The type of the vehicle
const SUMOVTypeParameter* const myType;
protected:
/// @brief Whether the last routing was successful
bool myRoutingSuccess;
private:
/// @brief Invalidated copy constructor
RORoutable(const RORoutable& src);
/// @brief Invalidated assignment operator
RORoutable& operator=(const RORoutable& src);
};