SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSBaseVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A base class for vehicle implementations
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2010-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 MSBaseVehicle_h
23 #define MSBaseVehicle_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 <iostream>
36 #include <vector>
37 #include <set>
39 #include <utils/common/StdDefs.h>
40 #include "MSRoute.h"
41 #include "MSMoveReminder.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
48 class MSVehicleType;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class MSBaseVehicle : public SUMOVehicle {
59 public:
67  MSBaseVehicle(SUMOVehicleParameter* pars, const MSRoute* route, const MSVehicleType* type, const SUMOReal speedFactor);
68 
69 
71  virtual ~MSBaseVehicle();
72 
73 
75  const std::string& getID() const;
76 
81  const SUMOVehicleParameter& getParameter() const;
82 
83 
87  inline const MSRoute& getRoute() const {
88  return *myRoute;
89  }
90 
91 
95  inline const MSVehicleType& getVehicleType() const {
96  return *myType;
97  }
98 
99 
103  SUMOReal getMaxSpeed() const;
104 
105 
113  const MSEdge* succEdge(unsigned int nSuccs) const;
114 
119  const MSEdge* getEdge() const;
120 
121 
125  virtual bool isOnRoad() const {
126  return true;
127  }
128 
129 
135  virtual const MSEdge* getRerouteOrigin() const {
136  return *myCurrEdge;
137  }
138 
139 
149  void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false);
150 
151 
162  bool replaceRouteEdges(MSEdgeVector& edges, bool onInit = false);
163 
164 
170  virtual SUMOReal getAcceleration() const;
171 
177  virtual SUMOReal getSlope() const;
178 
184  void onDepart();
185 
189  inline SUMOTime getDeparture() const {
190  return myDeparture;
191  }
192 
197  virtual SUMOReal getArrivalPos() const {
198  return myArrivalPos;
199  }
200 
203  bool hasDeparted() const;
204 
208  virtual bool hasArrived() const;
209 
213  inline unsigned int getNumberReroutes() const {
214  return myNumberReroutes;
215  }
216 
218  SUMOReal getImpatience() const;
219 
220 
224  inline const std::vector<MSDevice*>& getDevices() const {
225  return myDevices;
226  }
227 
234  virtual void addPerson(MSPerson* person);
235 
240  bool hasValidRoute(std::string& msg) const;
241 
247  void addReminder(MSMoveReminder* rem);
248 
254  void removeReminder(MSMoveReminder* rem);
255 
266  virtual void activateReminders(const MSMoveReminder::Notification reason);
267 
272  return myChosenSpeedFactor;
273  }
274 
278  inline void setChosenSpeedFactor(SUMOReal factor) {
279  myChosenSpeedFactor = factor;
280  }
281 
283  MSDevice* getDevice(const std::type_info& type) const;
284 
285 
287 
288 
290  virtual void saveState(OutputDevice& out);
291 
293 
294 protected:
297  void calculateArrivalPos();
298 
299 protected:
302 
304  const MSRoute* myRoute;
305 
308 
311 
314 
315 
318 
320  typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MoveReminderCont;
321 
325 
327  std::vector<MSDevice*> myDevices;
328 
331 
334 
336  unsigned int myNumberReroutes;
337 
338 private:
339  /* @brief magic value for undeparted vehicles
340  * @note: in previous versions this was -1
341  */
343 
346 
347 
348 #ifdef _DEBUG
349 public:
350  static void initMoveReminderOutput(const OptionsCont& oc);
351 
352 protected:
354  void traceMoveReminder(const std::string& type, MSMoveReminder* rem, SUMOReal pos, bool keep) const;
355 
357  const bool myTraceMoveReminders;
358 private:
360  static std::set<std::string> myShallTraceMoveReminders;
361 #endif
362 
363 
364 };
365 
366 #endif
367 
368 /****************************************************************************/