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-2013 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(const MSEdgeVector& edges, bool onInit = false) = 0;
107 
109  virtual bool replaceRoute(const MSRoute* route, bool onInit = false) = 0;
110 
120  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false) = 0;
121 
125  virtual SUMOReal getAcceleration() const = 0;
126 
131  virtual const MSEdge* getEdge() const = 0;
132 
137  virtual const SUMOVehicleParameter& getParameter() const = 0;
138 
144  virtual void onDepart() = 0;
145 
149  virtual bool isOnRoad() const = 0;
150 
154  virtual SUMOTime getDeparture() const = 0;
155 
160  virtual SUMOReal getArrivalPos() const = 0;
161 
164  virtual bool hasDeparted() const = 0;
165 
168  virtual bool hasArrived() const = 0;
169 
173  virtual unsigned int getNumberReroutes() const = 0;
174 
178  virtual const std::vector<MSDevice*>& getDevices() const = 0;
179 
186  virtual void addPerson(MSPerson* person) = 0;
187 
194  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, SUMOTime untilOffset = 0) = 0;
195 
199  virtual bool isStopped() const = 0;
200 
202  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
203 
204 
205  virtual SUMOReal getChosenSpeedFactor() const = 0;
206 
207  virtual SUMOTime getWaitingTime() const = 0;
208 
210 
211 
213  virtual void saveState(OutputDevice& out) = 0;
214 
217  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
219 };
220 
221 
222 #endif
223 
224 /****************************************************************************/
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&#39;th successor of edge the vehicle is currently at.
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false)=0
Replaces the current route by the given one.
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&#39;s position along the lane.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;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&#39;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 bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
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&#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.
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 getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
virtual bool replaceRouteEdges(const MSEdgeVector &edges, bool onInit=false)=0
Replaces the current route by the given edges.
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&#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.