Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RORoutable.h
Go to the documentation of this file.
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/****************************************************************************/
18// A routable thing such as a vehicle or person
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
24#include <iostream>
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35class OutputDevice;
36class ROEdge;
37class ROLane;
38class RONode;
39class ROVehicle;
40
41typedef std::vector<const ROEdge*> ConstROEdgeVector;
44
45
46// ===========================================================================
47// class definitions
48// ===========================================================================
54public:
61 myParameter(pars),
62 myType(type),
63 myRandomSeed(RandHelper::murmur3_32(pars.id, RandHelper::getSeed())),
64 myRoutingSuccess(false) {}
65
66
68 virtual ~RORoutable() {}
69
70
75 inline const SUMOVehicleParameter& getParameter() const {
76 return myParameter;
77 }
78
82
89 inline const SUMOVTypeParameter* getType() const {
90 return myType;
91 }
92
93
98 inline const std::string& getID() const {
99 return myParameter.id;
100 }
101
103 long long int getRandomSeed() const {
104 return myRandomSeed;
105 }
106
113
118 inline SUMOTime getDepart() const {
119 return myParameter.depart;
120 }
121
123 inline void setDepart(SUMOTime t) {
125 }
126
128 return getType() != 0 ? getType()->vehicleClass : SVC_IGNORING;
129 }
130
135 return false;
136 };
137
139 inline double getMaxSpeed() const {
140 return MIN2(getType()->maxSpeed,
141 getType()->desiredMaxSpeed * getChosenSpeedFactor());
142 }
143
144 virtual const ROEdge* getDepartEdge() const = 0;
145
146
147 inline bool isPublicTransport() const {
148 return myParameter.line != "";
149 }
150
151 inline bool isPartOfFlow() const {
152 return myParameter.repetitionNumber >= 0;
153 }
154
155 virtual void computeRoute(const RORouterProvider& provider,
156 const bool removeLoops, MsgHandler* errorHandler) = 0;
157
158
166 void write(OutputDevice* os, OutputDevice* const altos,
167 OutputDevice* const typeos, OptionsCont& options, int quota) const {
168 for (int i = 0; i < quota; i++) {
169 if (os != nullptr) {
170 if (altos == nullptr && typeos == nullptr) {
171 saveAsXML(*os, os, false, options, i);
172 } else {
173 saveAsXML(*os, typeos, false, options, i);
174 }
175 }
176 if (altos != nullptr) {
177 saveAsXML(*altos, typeos, true, options, i);
178 }
179 }
180 }
181
182
183 inline bool getRoutingSuccess() const {
184 return myRoutingSuccess;
185 }
186
187
188protected:
199 virtual void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const = 0;
200
201
202private:
205
208
210 const long long int myRandomSeed;
211
212protected:
215
216
217private:
220
223
224};
long long int SUMOTime
Definition GUI.h:36
IntermodalRouter< ROEdge, ROLane, RONode, ROVehicle > ROIntermodalRouter
Definition RORoutable.h:42
RouterProvider< ROEdge, ROLane, RONode, ROVehicle > RORouterProvider
Definition RORoutable.h:43
std::vector< const ROEdge * > ConstROEdgeVector
Definition RORoutable.h:41
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
const long long int VEHPARS_SPEEDFACTOR_SET
T MIN2(T a, T b)
Definition StdDefs.h:80
double getParameter(const int index) const
Returns the nth parameter of this distribution.
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
A basic edge for routing applications.
Definition ROEdge.h:73
A single lane the router may use.
Definition ROLane.h:48
Base class for nodes used by the router.
Definition RONode.h:46
A routable thing such as a vehicle or person.
Definition RORoutable.h:53
bool getRoutingSuccess() const
Definition RORoutable.h:183
SUMOVehicleParameter myParameter
The vehicle's parameter.
Definition RORoutable.h:204
bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
Definition RORoutable.h:134
RORoutable(const RORoutable &src)
Invalidated copy constructor.
const SUMOVTypeParameter *const myType
The type of the vehicle.
Definition RORoutable.h:207
virtual const ROEdge * getDepartEdge() const =0
SUMOVehicleClass getVClass() const
Definition RORoutable.h:127
long long int getRandomSeed() const
return vehicle-specific random number
Definition RORoutable.h:103
bool isPublicTransport() const
Definition RORoutable.h:147
SUMOVehicleParameter & getParameterMutable()
Definition RORoutable.h:79
bool isPartOfFlow() const
Definition RORoutable.h:151
RORoutable(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition RORoutable.h:60
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
RORoutable & operator=(const RORoutable &src)
Invalidated assignment operator.
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition RORoutable.h:118
bool myRoutingSuccess
Whether the last routing was successful.
Definition RORoutable.h:214
void write(OutputDevice *os, OutputDevice *const altos, OutputDevice *const typeos, OptionsCont &options, int quota) const
Saves the routable including the vehicle type (if it was not saved before).
Definition RORoutable.h:166
virtual void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options, int cloneIndex=0) const =0
Saves the complete routable description.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition RORoutable.h:89
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition RORoutable.h:110
void setDepart(SUMOTime t)
update depart time (for triggered persons)
Definition RORoutable.h:123
const std::string & getID() const
Returns the id of the routable.
Definition RORoutable.h:98
const long long int myRandomSeed
object-specific random constant
Definition RORoutable.h:210
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition RORoutable.h:75
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition RORoutable.h:139
virtual ~RORoutable()
Destructor.
Definition RORoutable.h:68
A vehicle as used by router.
Definition ROVehicle.h:51
Utility functions for using a global, resetable random number generator.
Definition RandHelper.h:133
Structure representing possible vehicle parameter.
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
SUMOVehicleClass vehicleClass
The vehicle's class.
Structure representing possible vehicle parameter.
double speedFactor
individual speedFactor (overriding distribution from vType)
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string id
The vehicle's id.
std::string line
The vehicle's line (mainly for public transport)