Eclipse SUMO - Simulation of Urban MObility
ROVehicle.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-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 // A vehicle as used by router
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <iostream>
27 #include <utils/common/StdDefs.h>
28 #include <utils/common/SUMOTime.h>
31 #include "RORoutable.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class OutputDevice;
38 class ROEdge;
39 class RONet;
40 class RORouteDef;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 class ROVehicle : public RORoutable {
51 public:
58  ROVehicle(const SUMOVehicleParameter& pars,
59  RORouteDef* route, const SUMOVTypeParameter* type,
60  const RONet* net, MsgHandler* errorHandler = 0);
61 
62 
64  virtual ~ROVehicle();
65 
66 
73  inline RORouteDef* getRouteDefinition() const {
74  return myRoute;
75  }
76 
77 
82  const ROEdge* getDepartEdge() const;
83 
84 
85  void computeRoute(const RORouterProvider& provider,
86  const bool removeLoops, MsgHandler* errorHandler);
87 
92  inline SUMOTime getDepartureTime() const {
93  return MAX2(SUMOTime(0), getParameter().depart);
94  }
95 
96 
97  inline const ConstROEdgeVector& getStopEdges() const {
98  return myStopEdges;
99  }
100 
101 
103  ConstROEdgeVector getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;
104 
109  inline double getChosenSpeedFactor() const {
110  return getType()->speedFactor.getMax();
111  }
112 
116  inline const SUMOVTypeParameter& getVehicleType() const {
117  return *getType();
118  }
119 
121  inline double getLength() const {
122  return getType()->length;
123  }
124 
125  inline bool hasJumps() const {
126  return myJumpTime >= 0;
127  }
128 
129  inline SUMOTime getJumpTime() const {
130  return myJumpTime;
131  }
132 
134  void collectJumps(const ConstROEdgeVector& mandatory, std::set<ConstROEdgeVector::const_iterator>& jumpStarts) const;
135 
146  void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
147 
148 
149 private:
155  void addStop(const SUMOVehicleParameter::Stop& stopPar,
156  const RONet* net, MsgHandler* errorHandler);
157 
158 private:
161 
164 
167 
169  static std::map<ConstROEdgeVector, std::string> mySavedRoutes;
170 
171 private:
173  ROVehicle(const ROVehicle& src);
174 
177 
178 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
T MAX2(T a, T b)
Definition: StdDefs.h:82
double getMax() const
Returns the maximum value 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.
Definition: OutputDevice.h:61
A basic edge for routing applications.
Definition: ROEdge.h:70
The router's network representation.
Definition: RONet.h:62
A routable thing such as a vehicle or person.
Definition: RORoutable.h:52
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:71
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:82
Base class for a vehicle's route definition.
Definition: RORouteDef.h:53
A vehicle as used by router.
Definition: ROVehicle.h:50
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:109
void collectJumps(const ConstROEdgeVector &mandatory, std::set< ConstROEdgeVector::const_iterator > &jumpStarts) const
collect mandatory-edge iterators that define jumps in the route
Definition: ROVehicle.cpp:214
const ConstROEdgeVector & getStopEdges() const
Definition: ROVehicle.h:97
static std::map< ConstROEdgeVector, std::string > mySavedRoutes
map of all routes that were already saved with a name
Definition: ROVehicle.h:169
SUMOTime getJumpTime() const
Definition: ROVehicle.h:129
const ROEdge * getDepartEdge() const
Returns the first edge the vehicle takes.
Definition: ROVehicle.cpp:136
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition: ROVehicle.h:73
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition: ROVehicle.h:92
ConstROEdgeVector getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
compute mandatory edges
Definition: ROVehicle.cpp:184
ROVehicle(const ROVehicle &src)
Invalidated copy constructor.
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete vehicle description.
Definition: ROVehicle.cpp:239
double getLength() const
Returns the vehicle's length.
Definition: ROVehicle.h:121
ConstROEdgeVector myStopEdges
The edges where the vehicle stops.
Definition: ROVehicle.h:163
ROVehicle(const SUMOVehicleParameter &pars, RORouteDef *route, const SUMOVTypeParameter *type, const RONet *net, MsgHandler *errorHandler=0)
Constructor.
Definition: ROVehicle.cpp:49
virtual ~ROVehicle()
Destructor.
Definition: ROVehicle.cpp:132
bool hasJumps() const
Definition: ROVehicle.h:125
ROVehicle & operator=(const ROVehicle &src)
Invalidated assignment operator.
SUMOTime myJumpTime
Whether this vehicle has any jumps defined.
Definition: ROVehicle.h:166
void addStop(const SUMOVehicleParameter::Stop &stopPar, const RONet *net, MsgHandler *errorHandler)
Adds a stop to this vehicle.
Definition: ROVehicle.cpp:77
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition: ROVehicle.cpp:142
RORouteDef *const myRoute
The route the vehicle takes.
Definition: ROVehicle.h:160
const SUMOVTypeParameter & getVehicleType() const
Returns the vehicle's type definition.
Definition: ROVehicle.h:116
Structure representing possible vehicle parameter.
double length
The physical vehicle length.
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.