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 <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;
53 
54 typedef std::vector<const MSEdge*> MSEdgeVector;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
64 class SUMOVehicle {
65 public:
67  virtual ~SUMOVehicle() {}
68 
72  virtual const std::string& getID() const = 0;
73 
77  virtual SUMOReal getPositionOnLane() const = 0;
78 
82  virtual SUMOReal getMaxSpeed() const = 0;
83 
87  virtual SUMOReal getSpeed() const = 0;
88 
92  virtual const MSVehicleType& getVehicleType() const = 0;
93 
95  virtual const MSRoute& getRoute() const = 0;
96 
104  virtual const MSEdge* succEdge(unsigned int nSuccs) const = 0;
105 
107  virtual bool replaceRouteEdges(MSEdgeVector& edges, bool onInit = false) = 0;
108 
110  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
111 
121  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false) = 0;
122 
126  virtual SUMOReal getAcceleration() const = 0;
127 
131  virtual SUMOReal getSlope() const = 0;
132 
137  virtual const MSEdge* getEdge() const = 0;
138 
143  virtual const SUMOVehicleParameter& getParameter() const = 0;
144 
150  virtual void onDepart() = 0;
151 
155  virtual bool isOnRoad() const = 0;
156 
160  virtual SUMOTime getDeparture() const = 0;
161 
166  virtual SUMOReal getArrivalPos() const = 0;
167 
170  virtual bool hasDeparted() const = 0;
171 
174  virtual bool hasArrived() const = 0;
175 
179  virtual unsigned int getNumberReroutes() const = 0;
180 
184  virtual const std::vector<MSDevice*>& getDevices() const = 0;
185 
192  virtual void addPerson(MSPerson* person) = 0;
193 
200  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, SUMOTime untilOffset = 0) = 0;
201 
205  virtual bool isStopped() const = 0;
206 
208  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
209 
210 
211  virtual SUMOReal getChosenSpeedFactor() const = 0;
212 
213  virtual SUMOTime getWaitingTime() const = 0;
214 
216  virtual SUMOReal getImpatience() const = 0;
217 
219 
220 
222  virtual void saveState(OutputDevice& out) = 0;
223 
226  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
228 };
229 
230 
231 #endif
232 
233 /****************************************************************************/
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:74
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:64
Encapsulated SAX-Attributes.
std::vector< const MSEdge * > MSEdgeVector
Definition: MSPerson.h:57
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:52
Abstract in-vehicle device.
Definition: MSDevice.h:69
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:71
#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:67
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.