SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2001-2014 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 <utils/common/SUMOTime.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSVehicleType;
46 class MSRoute;
47 class MSEdge;
48 class MSLane;
49 class MSDevice;
50 class MSPerson;
52 
53 typedef std::vector<const MSEdge*> MSEdgeVector;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
63 class SUMOVehicle {
64 public:
66  virtual ~SUMOVehicle() {}
67 
71  virtual const std::string& getID() const = 0;
72 
76  virtual SUMOReal getPositionOnLane() const = 0;
77 
81  virtual SUMOReal getMaxSpeed() const = 0;
82 
86  virtual SUMOReal getSpeed() const = 0;
87 
91  virtual const MSVehicleType& getVehicleType() const = 0;
92 
94  virtual const MSRoute& getRoute() const = 0;
95 
103  virtual const MSEdge* succEdge(unsigned int nSuccs) const = 0;
104 
106  virtual bool replaceRouteEdges(MSEdgeVector& edges, bool onInit = false) = 0;
107 
109  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
110 
120  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false) = 0;
121 
125  virtual SUMOReal getAcceleration() const = 0;
126 
130  virtual SUMOReal getSlope() const = 0;
131 
136  virtual const MSEdge* getEdge() const = 0;
137 
142  virtual const SUMOVehicleParameter& getParameter() const = 0;
143 
149  virtual void onDepart() = 0;
150 
154  virtual bool isOnRoad() const = 0;
155 
159  virtual SUMOTime getDeparture() const = 0;
160 
165  virtual SUMOReal getArrivalPos() const = 0;
166 
169  virtual bool hasDeparted() const = 0;
170 
173  virtual bool hasArrived() const = 0;
174 
178  virtual unsigned int getNumberReroutes() const = 0;
179 
183  virtual const std::vector<MSDevice*>& getDevices() const = 0;
184 
191  virtual void addPerson(MSPerson* person) = 0;
192 
199  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, SUMOTime untilOffset = 0) = 0;
200 
204  virtual bool isStopped() const = 0;
205 
207  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
208 
209 
210  virtual SUMOReal getChosenSpeedFactor() const = 0;
211 
212  virtual SUMOTime getWaitingTime() const = 0;
213 
215  virtual SUMOReal getImpatience() const = 0;
216 
218 
219 
221  virtual void saveState(OutputDevice& out) = 0;
222 
225  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
227 };
228 
229 
230 #endif
231 
232 /****************************************************************************/
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual void addPerson(MSPerson *person)=0
Adds a person to this vehicle.
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 void onDepart()=0
Called when the vehicle is inserted into the network.
virtual void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false)=0
Performs a rerouting using the given router.
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 bool replaceRouteEdges(MSEdgeVector &edges, bool onInit=false)=0
Replaces the current route by the given edges.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle's maximum speed.
The car-following model and parameter.
Definition: MSVehicleType.h:74
virtual SUMOReal getChosenSpeedFactor() const =0
A road/street connecting two junctions.
Definition: MSEdge.h:73
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle's devices.
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
Representation of a vehicle.
Definition: SUMOVehicle.h:63
Encapsulated SAX-Attributes.
std::vector< const MSEdge * > MSEdgeVector
Definition: MSPerson.h:53
virtual SUMOReal getImpatience() const =0
Returns this vehicles impatience.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
std::vector< const MSEdge * > MSEdgeVector
Definition: SUMOVehicle.h:51
Abstract in-vehicle device.
Definition: MSDevice.h:68
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, SUMOTime untilOffset=0)=0
Adds a stop.
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.
int SUMOTime
Definition: SUMOTime.h:43
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:70
#define SUMOReal
Definition: config.h:215
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 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:66
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.