Eclipse SUMO - Simulation of Urban MObility
RORoute.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 /****************************************************************************/
21 // A complete router's route
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <utils/common/Named.h>
28 #include <utils/common/RGBColor.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class ROEdge;
37 class ROVehicle;
38 class OutputDevice;
39 
40 typedef std::vector<const ROEdge*> ConstROEdgeVector;
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
52 class RORoute : public Named {
53 public:
64  RORoute(const std::string& id, double costs, double prob,
65  const ConstROEdgeVector& route, const RGBColor* const color,
66  const std::vector<SUMOVehicleParameter::Stop>& stops);
67 
68 
74  RORoute(const std::string& id, const ConstROEdgeVector& route);
75 
80  RORoute(const RORoute& src);
81 
82 
84  ~RORoute();
85 
86 
91  const ROEdge* getFirst() const {
92  return myRoute[0];
93  }
94 
95 
100  const ROEdge* getLast() const {
101  return myRoute.back();
102  }
103 
104 
110  double getCosts() const {
111  return myCosts;
112  }
113 
114 
120  double getProbability() const {
121  return myProbability;
122  }
123 
124 
129  void setCosts(double costs);
130 
131 
136  void setProbability(double prob);
137 
138 
143  int size() const {
144  return (int) myRoute.size();
145  }
146 
147 
153  return myRoute;
154  }
155 
160  const RGBColor* getColor() const {
161  return myColor;
162  }
163 
164 
167  void recheckForLoops(const ConstROEdgeVector& mandatory);
168 
169 
171  bool isValid(const ROVehicle& veh, bool ignoreErrors) const;
172 
173  OutputDevice&
174  writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
175  const bool withCosts, const bool withProb,
176  const bool withExitTimes, const bool withLength,
177  const std::string& id = "") const;
178 
181  void addProbability(double prob);
182 
187  const std::vector<SUMOVehicleParameter::Stop>& getStops() const {
188  return myStops;
189  }
190 
193  void addStopOffset(const SUMOTime offset) {
194  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = myStops.begin(); stop != myStops.end(); ++stop) {
195  if (stop->until >= 0) {
196  stop->until += offset;
197  }
198  }
199  }
200 
203 
204 private:
206  double myCosts;
207 
210 
213 
216 
218  std::vector<SUMOVehicleParameter::Stop> myStops;
219 
220 
221 private:
223  RORoute& operator=(const RORoute& src);
224 
225 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
std::vector< const ROEdge * > ConstROEdgeVector
Definition: RORoute.h:38
Base class for objects which have an id.
Definition: Named.h:54
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
A complete router's route.
Definition: RORoute.h:52
double getCosts() const
Returns the costs of the route.
Definition: RORoute.h:110
const ROEdge * getFirst() const
Returns the first edge in the route.
Definition: RORoute.h:91
ConstROEdgeVector myRoute
The edges the route consists of.
Definition: RORoute.h:212
double myCosts
The costs of the route.
Definition: RORoute.h:206
void setProbability(double prob)
Sets the probability of the route.
Definition: RORoute.cpp:70
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
Definition: RORoute.h:187
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:120
double myProbability
The probability the driver will take this route with.
Definition: RORoute.h:209
int size() const
Returns the number of edges in this route.
Definition: RORoute.h:143
void addStopOffset(const SUMOTime offset)
Adapts the until time of all stops by the given offset.
Definition: RORoute.h:193
RORoute(const std::string &id, double costs, double prob, const ConstROEdgeVector &route, const RGBColor *const color, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
Definition: RORoute.cpp:38
RORoute & operator=(const RORoute &src)
Invalidated assignment operator.
void addProbability(double prob)
add additional vehicles/probability
Definition: RORoute.cpp:96
const RGBColor * myColor
The color of the route.
Definition: RORoute.h:215
~RORoute()
Destructor.
Definition: RORoute.cpp:58
const RGBColor * getColor() const
Returns this route's color.
Definition: RORoute.h:160
ConstROEdgeVector getNormalEdges() const
return edges that shall be written in the route definition
Definition: RORoute.cpp:102
void recheckForLoops(const ConstROEdgeVector &mandatory)
Checks whether this route contains loops and removes such.
Definition: RORoute.cpp:76
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition: RORoute.h:152
const ROEdge * getLast() const
Returns the last edge in the route.
Definition: RORoute.h:100
void setCosts(double costs)
Sets the costs of the route.
Definition: RORoute.cpp:64
std::vector< SUMOVehicleParameter::Stop > myStops
List of the stops on the parsed route.
Definition: RORoute.h:218
bool isValid(const ROVehicle &veh, bool ignoreErrors) const
check whether the route is valid for the given vehicle
Definition: RORoute.cpp:81
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withProb, const bool withExitTimes, const bool withLength, const std::string &id="") const
Definition: RORoute.cpp:114
A vehicle as used by router.
Definition: ROVehicle.h:50