Eclipse SUMO - Simulation of Urban MObility
RORouteDef.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 // Base class for a vehicle's route definition
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <iostream>
27 #include <utils/common/Named.h>
29 #include "RORoute.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class ROEdge;
36 class OptionsCont;
37 class ROVehicle;
38 class OutputDevice;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
53 class RORouteDef : public Named {
54 public:
60  RORouteDef(const std::string& id, const int lastUsed,
61  const bool tryRepair, const bool mayBeDisconnected);
62 
63 
65  virtual ~RORouteDef();
66 
67 
70  void addLoadedAlternative(RORoute* alternative);
71 
73  void addAlternativeDef(const RORouteDef* alternative);
74 
78  const ROVehicle& veh) const;
79 
83  const ROVehicle& veh) const;
84 
88  const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges) const;
89 
94  const ROVehicle* const, RORoute* current, SUMOTime begin);
95 
96  const ROEdge* getDestination() const;
97 
98  const RORoute* getFirstRoute() const {
99  if (myAlternatives.empty()) {
100  return 0;
101  }
102  return myAlternatives.front();
103  }
104 
105  const RORoute* getUsedRoute() const {
106  return myAlternatives[myLastUsed];
107  }
108 
117  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
118  bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const;
119 
120 
130  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
131 
133  double getOverallProb() const;
134 
135 
137  bool discardSilent() const {
138  return myDiscardSilent;
139  }
140 
141 
142  static void setUsingJTRR() {
143  myUsingJTRR = true;
144  }
145 
146 protected:
149 
151  mutable int myLastUsed;
152 
154  std::vector<RORoute*> myAlternatives;
155 
157  std::set<RORoute*> myRouteRefs;
158 
160  mutable bool myNewRoute;
161 
162  const bool myTryRepair;
164 
166  mutable bool myDiscardSilent;
167 
168  static bool myUsingJTRR;
169 
170 private:
172  RORouteDef(const RORouteDef& src) = delete;
173 
175  RORouteDef& operator=(const RORouteDef& src) = delete;
176 
177 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
Base class for objects which have an id.
Definition: Named.h:54
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
Base class for a vehicle's route definition.
Definition: RORouteDef.h:53
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:148
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition: RORouteDef.cpp:69
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:50
RORouteDef & operator=(const RORouteDef &src)=delete
Invalidated assignment operator.
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:431
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:154
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:402
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
Definition: RORouteDef.cpp:84
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:98
const bool myMayBeDisconnected
Definition: RORouteDef.h:163
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
static void setUsingJTRR()
Definition: RORouteDef.h:142
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:59
bool myDiscardSilent
Whether this route should be silently discarded.
Definition: RORouteDef.h:166
RORouteDef(const RORouteDef &src)=delete
Invalidated copy constructor.
void preComputeCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Builds the complete route (or chooses her from the list of alternatives, when existing)
Definition: RORouteDef.cpp:94
static bool myUsingJTRR
Definition: RORouteDef.h:168
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:160
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:287
const bool myTryRepair
Definition: RORouteDef.h:162
const RORoute * getUsedRoute() const
Definition: RORouteDef.h:105
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:151
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:157
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:396
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:418
bool repairCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh, ConstROEdgeVector oldEdges, ConstROEdgeVector &newEdges) const
Builds the complete route (or chooses her from the list of alternatives, when existing)
Definition: RORouteDef.cpp:165
bool discardSilent() const
whether this route shall be silently discarded
Definition: RORouteDef.h:137
A complete router's route.
Definition: RORoute.h:52
A vehicle as used by router.
Definition: ROVehicle.h:50