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 MSContainer;
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 const MSVehicleType& getVehicleType() const = 0;
108 
112  virtual SUMOVehicleClass getVClass() const = 0;
113 
115  virtual const MSRoute& getRoute() const = 0;
116 
124  virtual const MSEdge* succEdge(unsigned int nSuccs) const = 0;
125 
127  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit = false) = 0;
128 
130  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
131 
141  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false) = 0;
142 
143 
147  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
148 
152  virtual SUMOReal getAcceleration() const = 0;
153 
157  virtual SUMOReal getSlope() const = 0;
158 
163  virtual const MSEdge* getEdge() const = 0;
164 
169  virtual const SUMOVehicleParameter& getParameter() const = 0;
170 
176  virtual void onDepart() = 0;
177 
181  virtual bool isOnRoad() const = 0;
182 
186  virtual SUMOTime getDeparture() const = 0;
187 
192  virtual SUMOReal getArrivalPos() const = 0;
193 
196  virtual bool hasDeparted() const = 0;
197 
200  virtual bool hasArrived() const = 0;
201 
205  virtual unsigned int getNumberReroutes() const = 0;
206 
210  virtual const std::vector<MSDevice*>& getDevices() const = 0;
211 
218  virtual void addPerson(MSPerson* person) = 0;
219 
226  virtual void addContainer(MSContainer* container) = 0;
227 
234  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0) = 0;
235 
239  virtual bool isStopped() const = 0;
240 
241 
244  virtual bool isStoppedTriggered() const = 0;
245 
247  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
248 
249 
250  virtual SUMOReal getChosenSpeedFactor() const = 0;
251 
252  virtual void setChosenSpeedFactor(const SUMOReal factor) = 0;
253 
254  virtual SUMOTime getWaitingTime() const = 0;
255 
257  virtual SUMOReal getImpatience() const = 0;
258 
260 
261 
263  virtual void saveState(OutputDevice& out) = 0;
264 
267  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
269 };
270 
271 
272 #endif
273 
274 /****************************************************************************/
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual void addPerson(MSPerson *person)=0
Adds a person to this vehicle.
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'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 SUMOReal getPositionOnLane() const =0
Get the vehicle'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's angle.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle's maximum speed.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
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 SUMOReal getChosenSpeedFactor() const =0
A road/street connecting two junctions.
Definition: MSEdge.h:81
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle'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 addContainer(MSContainer *container)=0
Adds a container to this vehicle.
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 SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
Structure representing possible vehicle parameter.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasArrived() const =0
Returns whether this vehicle has arrived.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
Definition of vehicle stop (position and duration)
virtual SUMOReal getAcceleration() const =0
Returns the vehicle'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)
int SUMOTime
Definition: SUMOTime.h:43
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false)=0
Replaces the current route by the given edges.
virtual SUMOTime getWaitingTime() const =0
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:218
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'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'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'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's type.