Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-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/****************************************************************************/
20// A vehicle as used by router
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
26#include <iostream>
31#include "RORoutable.h"
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class OutputDevice;
38class ROEdge;
39class RORoute;
40class RONet;
41class RORouteDef;
42
43
44// ===========================================================================
45// class definitions
46// ===========================================================================
51class ROVehicle : public RORoutable {
52public:
60 RORouteDef* route, const SUMOVTypeParameter* type,
61 const RONet* net, MsgHandler* errorHandler = 0);
62
63
65 virtual ~ROVehicle();
66
67
75 return myRoute;
76 }
77
78
83 const ROEdge* getDepartEdge() const;
84
85
86 void computeRoute(const RORouterProvider& provider,
87 const bool removeLoops, MsgHandler* errorHandler);
88
93 inline SUMOTime getDepartureTime() const {
94 return MAX2(SUMOTime(0), getParameter().depart);
95 }
96
97
99 struct Mandatory {
100 Mandatory(const ROEdge* e, double p, SUMOTime jump = -1):
101 edge(e),
102 pos(p),
103 isJump(jump >= 0) {}
104
105 const ROEdge* edge;
106 double pos;
107 bool isJump;
108 };
109
110 std::vector<Mandatory> getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;
111
115 inline const SUMOVTypeParameter& getVTypeParameter() const {
116 return *getType();
117 }
118
120 inline double getLength() const {
121 return getType()->length;
122 }
123
124 inline bool hasJumps() const {
125 return myJumpTime >= 0;
126 }
127
128 inline SUMOTime getJumpTime() const {
129 return myJumpTime;
130 }
131
142 void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const;
143
144
145private:
151 void addStop(const SUMOVehicleParameter::Stop& stopPar,
152 const RONet* net, MsgHandler* errorHandler);
153
155 void updateIndex(const RORoute* replaced, const RORoute* current, int& attr);
156
157private:
160
163
165 static std::map<ConstROEdgeVector, std::string> mySavedRoutes;
166
167private:
169 ROVehicle(const ROVehicle& src);
170
173
174};
long long int SUMOTime
Definition GUI.h:36
T MAX2(T a, T b)
Definition StdDefs.h:86
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
The router's network representation.
Definition RONet.h:63
A routable thing such as a vehicle or person.
Definition RORoutable.h:53
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition RORoutable.h:89
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition RORoutable.h:75
Base class for a vehicle's route definition.
Definition RORouteDef.h:53
A complete router's route.
Definition RORoute.h:52
A vehicle as used by router.
Definition ROVehicle.h:51
ROVehicle & operator=(const ROVehicle &src)
Invalidated assignment operator.
static std::map< ConstROEdgeVector, std::string > mySavedRoutes
map of all routes that were already saved with a name
Definition ROVehicle.h:165
SUMOTime getJumpTime() const
Definition ROVehicle.h:128
const ROEdge * getDepartEdge() const
Returns the first edge the vehicle takes.
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition ROVehicle.h:93
ROVehicle(const ROVehicle &src)
Invalidated copy constructor.
double getLength() const
Returns the vehicle's length.
Definition ROVehicle.h:120
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition ROVehicle.h:74
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options, int cloneIndex=0) const
Saves the complete vehicle description.
virtual ~ROVehicle()
Destructor.
bool hasJumps() const
Definition ROVehicle.h:124
SUMOTime myJumpTime
Whether this vehicle has any jumps defined.
Definition ROVehicle.h:162
std::vector< Mandatory > getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
void updateIndex(const RORoute *replaced, const RORoute *current, int &attr)
update departEdge / arrivalEdge
void addStop(const SUMOVehicleParameter::Stop &stopPar, const RONet *net, MsgHandler *errorHandler)
Adds a stop to this vehicle.
Definition ROVehicle.cpp:70
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
const SUMOVTypeParameter & getVTypeParameter() const
Returns the vehicle's type definition.
Definition ROVehicle.h:115
RORouteDef *const myRoute
The route the vehicle takes.
Definition ROVehicle.h:159
Structure representing possible vehicle parameter.
double length
The physical vehicle length.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
information for mandatory edges
Definition ROVehicle.h:99
const ROEdge * edge
Definition ROVehicle.h:105
Mandatory(const ROEdge *e, double p, SUMOTime jump=-1)
Definition ROVehicle.h:100