SUMO - Simulation of Urban MObility
SUMOVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Abstract base class for vehicle representations
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMOVehicle_h
23 #define SUMOVehicle_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <typeinfo>
37 #include <utils/common/SUMOTime.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class MSVehicleType;
47 class MSRoute;
48 class MSEdge;
49 class MSLane;
50 class MSDevice;
51 class MSPerson;
52 class MSTransportable;
54 
55 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
65 class SUMOVehicle {
66 public:
68  virtual ~SUMOVehicle() {}
69 
73  virtual const std::string& getID() const = 0;
74 
78  virtual SUMOReal getPositionOnLane() const = 0;
79 
83  virtual SUMOReal getAngle() const = 0;
84 
92  virtual Position getPosition(const SUMOReal offset = 0) const = 0;
93 
97  virtual SUMOReal getMaxSpeed() const = 0;
98 
102  virtual SUMOReal getSpeed() const = 0;
103 
107  virtual MSLane* getLane() const = 0;
108 
112  virtual const MSVehicleType& getVehicleType() const = 0;
113 
117  virtual SUMOVehicleClass getVClass() const = 0;
118 
120  virtual const MSRoute& getRoute() const = 0;
121 
129  virtual const MSEdge* succEdge(unsigned int nSuccs) const = 0;
130 
132  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit = false) = 0;
133 
135  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
136 
146  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false) = 0;
147 
152  virtual bool hasValidRoute(std::string& msg) const = 0;
153 
154 
158  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
159 
163  virtual SUMOReal getAcceleration() const = 0;
164 
168  virtual SUMOReal getSlope() const = 0;
169 
174  virtual const MSEdge* getEdge() const = 0;
175 
180  virtual const SUMOVehicleParameter& getParameter() const = 0;
181 
187  virtual void onDepart() = 0;
188 
192  virtual bool isOnRoad() const = 0;
193 
197  virtual bool isParking() const = 0;
198 
202  virtual SUMOTime getDeparture() const = 0;
203 
208  virtual SUMOReal getArrivalPos() const = 0;
209 
212  virtual void setArrivalPos(SUMOReal arrivalPos) = 0;
213 
216  virtual bool hasDeparted() const = 0;
217 
220  virtual bool hasArrived() const = 0;
221 
225  virtual unsigned int getNumberReroutes() const = 0;
226 
230  virtual const std::vector<MSDevice*>& getDevices() const = 0;
231 
238  virtual void addPerson(MSTransportable* person) = 0;
239 
246  virtual void addContainer(MSTransportable* container) = 0;
247 
254  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0) = 0;
255 
259  virtual bool isStopped() const = 0;
260 
261 
264  virtual bool isStoppedTriggered() const = 0;
265 
267  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
268 
269 
270  virtual SUMOReal getChosenSpeedFactor() const = 0;
271 
272  virtual void setChosenSpeedFactor(const SUMOReal factor) = 0;
273 
274  virtual SUMOTime getWaitingTime() const = 0;
275 
276  virtual SUMOTime getDepartDelay() const = 0;
277 
279  virtual SUMOReal getImpatience() const = 0;
280 
282 
283 
285  virtual void saveState(OutputDevice& out) = 0;
286 
289  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
291 };
292 
293 
294 #endif
295 
296 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:43
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual const MSEdge * succEdge(unsigned int nSuccs) const =0
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
virtual bool isStoppedTriggered() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue...
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
virtual bool hasValidRoute(std::string &msg) const =0
Validates the current route.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual SUMOReal getAngle() const =0
Get the vehicle&#39;s angle.
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
The car-following model and parameter.
Definition: MSVehicleType.h:74
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0)=0
Adds a stop.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:53
virtual void addContainer(MSTransportable *container)=0
Adds a container to this vehicle.
virtual SUMOReal getChosenSpeedFactor() const =0
A road/street connecting two junctions.
Definition: MSEdge.h:81
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle&#39;s devices.
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
Encapsulated SAX-Attributes.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual SUMOReal getImpatience() const =0
Returns this vehicles impatience.
virtual void setArrivalPos(SUMOReal arrivalPos)=0
Sets this vehicle&#39;s desired arrivalPos for its current route.
virtual void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)=0
Performs a rerouting using the given router.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
Abstract in-vehicle device.
Definition: MSDevice.h:69
virtual SUMOTime getDepartDelay() const =0
virtual SUMOReal getSpeed() const =0
Returns the vehicle&#39;s current speed.
Structure representing possible vehicle parameter.
virtual SUMOTime getDeparture() const =0
Returns this vehicle&#39;s real departure time.
virtual bool hasArrived() const =0
Returns whether this vehicle has arrived.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
Definition of vehicle stop (position and duration)
virtual SUMOReal getAcceleration() const =0
Returns the vehicle&#39;s acceleration.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)=0
Replaces the current route by the given one.
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false)=0
Replaces the current route by the given edges.
virtual SUMOTime getWaitingTime() const =0
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual SUMOReal getSlope() const =0
Returns the slope of the road at vehicle&#39;s position.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual SUMOReal getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
virtual unsigned int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:68
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.