Eclipse SUMO - Simulation of Urban MObility
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-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 /****************************************************************************/
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>
25 #include <utils/common/StdDefs.h>
26 #include <utils/common/SUMOTime.h>
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class OutputDevice;
35 class ROEdge;
36 class ROLane;
37 class RONode;
38 class ROVehicle;
39 
40 typedef std::vector<const ROEdge*> ConstROEdgeVector;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
52 class RORoutable {
53 public:
60  : myParameter(pars), myType(type), myRoutingSuccess(false) {}
61 
62 
64  virtual ~RORoutable() {}
65 
66 
71  inline const SUMOVehicleParameter& getParameter() const {
72  return myParameter;
73  }
74 
75 
82  inline const SUMOVTypeParameter* getType() const {
83  return myType;
84  }
85 
86 
91  inline const std::string& getID() const {
92  return myParameter.id;
93  }
94 
95 
100  inline SUMOTime getDepart() const {
101  return myParameter.depart;
102  }
103 
105  inline void setDepart(SUMOTime t) {
106  myParameter.depart = t;
107  }
108 
109  inline SUMOVehicleClass getVClass() const {
110  return getType() != 0 ? getType()->vehicleClass : SVC_IGNORING;
111  }
112 
117  return false;
118  };
119 
121  inline double getMaxSpeed() const {
122  return MIN2(getType()->maxSpeed,
123  getType()->desiredMaxSpeed * getType()->speedFactor.getParameter()[0]);
124  }
125 
126  virtual const ROEdge* getDepartEdge() const = 0;
127 
128 
129  inline bool isPublicTransport() const {
130  return myParameter.line != "";
131  }
132 
133  inline bool isPartOfFlow() const {
134  return myParameter.repetitionNumber >= 0;
135  }
136 
137  virtual void computeRoute(const RORouterProvider& provider,
138  const bool removeLoops, MsgHandler* errorHandler) = 0;
139 
140 
148  void write(OutputDevice* os, OutputDevice* const altos,
149  OutputDevice* const typeos, OptionsCont& options) const {
150  if (os != nullptr) {
151  if (altos == nullptr && typeos == nullptr) {
152  saveAsXML(*os, os, false, options);
153  } else {
154  saveAsXML(*os, typeos, false, options);
155  }
156  }
157  if (altos != nullptr) {
158  saveAsXML(*altos, typeos, true, options);
159  }
160  }
161 
162 
163  inline bool getRoutingSuccess() const {
164  return myRoutingSuccess;
165  }
166 
167 
168 protected:
179  virtual void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const = 0;
180 
181 
182 private:
185 
188 
189 protected:
192 
193 
194 private:
196  RORoutable(const RORoutable& src);
197 
200 
201 };
long long int SUMOTime
Definition: GUI.h:35
IntermodalRouter< ROEdge, ROLane, RONode, ROVehicle > ROIntermodalRouter
Definition: RORoutable.h:41
RouterProvider< ROEdge, ROLane, RONode, ROVehicle > RORouterProvider
Definition: RORoutable.h:42
std::vector< const ROEdge * > ConstROEdgeVector
Definition: RORoutable.h:38
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
T MIN2(T a, T b)
Definition: StdDefs.h:76
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
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A basic edge for routing applications.
Definition: ROEdge.h:70
A single lane the router may use.
Definition: ROLane.h:48
Base class for nodes used by the router.
Definition: RONode.h:43
A routable thing such as a vehicle or person.
Definition: RORoutable.h:52
bool getRoutingSuccess() const
Definition: RORoutable.h:163
SUMOVehicleParameter myParameter
The vehicle's parameter.
Definition: RORoutable.h:184
bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
Definition: RORoutable.h:116
RORoutable(const RORoutable &src)
Invalidated copy constructor.
const SUMOVTypeParameter *const myType
The type of the vehicle.
Definition: RORoutable.h:187
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:71
const std::string & getID() const
Returns the id of the routable.
Definition: RORoutable.h:91
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:109
bool isPublicTransport() const
Definition: RORoutable.h:129
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:82
bool isPartOfFlow() const
Definition: RORoutable.h:133
RORoutable(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition: RORoutable.h:59
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:100
bool myRoutingSuccess
Whether the last routing was successful.
Definition: RORoutable.h:191
virtual const ROEdge * getDepartEdge() const =0
void write(OutputDevice *os, OutputDevice *const altos, OutputDevice *const typeos, OptionsCont &options) const
Saves the routable including the vehicle type (if it was not saved before).
Definition: RORoutable.h:148
void setDepart(SUMOTime t)
update depart time (for triggered persons)
Definition: RORoutable.h:105
RORoutable & operator=(const RORoutable &src)
Invalidated assignment operator.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition: RORoutable.h:121
virtual ~RORoutable()
Destructor.
Definition: RORoutable.h:64
virtual void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const =0
Saves the complete routable description.
A vehicle as used by router.
Definition: ROVehicle.h:50
Structure representing possible vehicle parameter.
SUMOVehicleClass vehicleClass
The vehicle's class.
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
std::string line
The vehicle's line (mainly for public transport)