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-2016 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>
38 #include <utils/common/Named.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSVehicleType;
48 class MSRoute;
49 class MSEdge;
50 class MSLane;
51 class MSDevice;
52 class MSPerson;
53 class MSTransportable;
55 
56 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
57 
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
66 class SUMOVehicle {
67 public:
68 
69  // XXX: This definition was introduced to make the MSVehicle's previousSpeed
70  // available in the context of MSMoveReminder::notifyMove(). Another solution
71  // would be to modify notifyMove()'s interface to work with MSVehicle instead
72  // of SUMOVehicle (it is only called with MSVehicles!). Refs. #2579
76  virtual SUMOReal getPreviousSpeed() const = 0;
77 
78 
80 
82  virtual ~SUMOVehicle() {}
83 
87  virtual const std::string& getID() const = 0;
88 
92  virtual SUMOReal getPositionOnLane() const = 0;
93 
97  virtual SUMOReal getBackPositionOnLane(const MSLane* lane) const = 0;
98 
103  virtual SUMOReal getLateralPositionOnLane() const = 0;
104 
108  virtual SUMOReal getAngle() const = 0;
109 
117  virtual Position getPosition(const SUMOReal offset = 0) const = 0;
118 
122  virtual SUMOReal getMaxSpeed() const = 0;
123 
127  virtual SUMOReal getSpeed() const = 0;
128 
132  virtual MSLane* getLane() const = 0;
133 
137  virtual const MSVehicleType& getVehicleType() const = 0;
138 
142  virtual SUMOVehicleClass getVClass() const = 0;
143 
145  virtual const MSRoute& getRoute() const = 0;
146 
154  virtual const MSEdge* succEdge(int nSuccs) const = 0;
155 
167  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit = false, bool check = false) = 0;
168 
170  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
171 
181  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false) = 0;
182 
188  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
189 
190 
194  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
195 
199  virtual SUMOReal getAcceleration() const = 0;
200 
204  virtual SUMOReal getSlope() const = 0;
205 
210  virtual const MSEdge* getEdge() const = 0;
211 
216  virtual const SUMOVehicleParameter& getParameter() const = 0;
217 
223  virtual void onDepart() = 0;
224 
228  virtual bool isOnRoad() const = 0;
229 
233  virtual bool isFrontOnLane(const MSLane*) const = 0;
234 
238  virtual bool isParking() const = 0;
239 
244  virtual bool isRemoteControlled() const = 0;
245 
249  virtual SUMOTime getDeparture() const = 0;
250 
254  virtual SUMOReal getDepartPos() const = 0;
255 
260  virtual SUMOReal getArrivalPos() const = 0;
261 
264  virtual void setArrivalPos(SUMOReal arrivalPos) = 0;
265 
268  virtual bool hasDeparted() const = 0;
269 
272  virtual bool hasArrived() const = 0;
273 
277  virtual int getNumberReroutes() const = 0;
278 
282  virtual const std::vector<MSDevice*>& getDevices() const = 0;
283 
290  virtual void addPerson(MSTransportable* person) = 0;
291 
298  virtual void addContainer(MSTransportable* container) = 0;
299 
306  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0) = 0;
307 
311  virtual bool isStopped() const = 0;
312 
313 
316  virtual bool isStoppedTriggered() const = 0;
317 
319  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
320 
321 
322  virtual SUMOReal getChosenSpeedFactor() const = 0;
323 
324  virtual void setChosenSpeedFactor(const SUMOReal factor) = 0;
325 
326  virtual SUMOTime getWaitingTime() const = 0;
327 
328  virtual SUMOTime getDepartDelay() const = 0;
329 
331  virtual SUMOReal getImpatience() const = 0;
332 
334 
335 
337  virtual void saveState(OutputDevice& out) = 0;
338 
341  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
343 };
344 
345 
346 #endif
347 
348 /****************************************************************************/
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...
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle) ...
Definition: Named.h:90
virtual const MSRoute & getRoute() const =0
Returns the current route.
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.
Named::NamedLikeComparatorIdLess< SUMOVehicle > ComparatorIdLess
Definition: SUMOVehicle.h:79
virtual SUMOReal getDepartPos() const =0
Returns this vehicle&#39;s real departure position.
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 getPreviousSpeed() const =0
Returns the vehicle&#39;s previous speed.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
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:54
virtual void addContainer(MSTransportable *container)=0
Adds a container to this vehicle.
virtual SUMOReal getChosenSpeedFactor() const =0
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
A road/street connecting two junctions.
Definition: MSEdge.h:80
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:66
Encapsulated SAX-Attributes.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual bool hasValidRoute(std::string &msg, const MSRoute *route=0) const =0
Validates the current or given route.
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 isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual SUMOReal getLateralPositionOnLane() const =0
Get the vehicle&#39;s lateral position on the lane.
Abstract in-vehicle device.
Definition: MSDevice.h:69
virtual SUMOTime getDepartDelay() const =0
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false)=0
Replaces the current route by the given edges.
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 SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle&#39;s back position along the given lane.
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:213
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:79
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:82
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.