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 /****************************************************************************/
8 // A base class for vehicle implementations
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSBaseVehicle_h
22 #define MSBaseVehicle_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <iostream>
35 #include <vector>
37 #include <utils/common/StdDefs.h>
38 #include "MSRoute.h"
39 #include "MSMoveReminder.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
46 class MSVehicleType;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
56 class MSBaseVehicle : public SUMOVehicle {
57 public:
65  MSBaseVehicle(SUMOVehicleParameter* pars, const MSRoute* route, const MSVehicleType* type, SUMOReal speedFactor);
66 
67 
69  virtual ~MSBaseVehicle();
70 
71 
73  const std::string& getID() const;
74 
79  const SUMOVehicleParameter& getParameter() const;
80 
81 
85  const MSRoute& getRoute() const;
86 
87 
91  const MSVehicleType& getVehicleType() const;
92 
93 
97  SUMOReal getMaxSpeed() const;
98 
99 
107  const MSEdge* succEdge(unsigned int nSuccs) const;
108 
113  const MSEdge* getEdge() const;
114 
115 
119  virtual bool isOnRoad() const {
120  return true;
121  }
122 
123 
133  void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false);
134 
135 
146  bool replaceRouteEdges(const MSEdgeVector& edges, bool onInit = false);
147 
148 
154  virtual SUMOReal getAcceleration() const;
155 
161  void onDepart();
162 
166  inline SUMOTime getDeparture() const {
167  return myDeparture;
168  }
169 
174  virtual SUMOReal getArrivalPos() const {
175  return myArrivalPos;
176  }
177 
180  bool hasDeparted() const;
181 
185  virtual bool hasArrived() const;
186 
190  inline unsigned int getNumberReroutes() const {
191  return myNumberReroutes;
192  }
193 
197  inline const std::vector<MSDevice*>& getDevices() const {
198  return myDevices;
199  }
200 
207  virtual void addPerson(MSPerson* person);
208 
213  bool hasValidRoute(std::string& msg) const;
214 
220  void addReminder(MSMoveReminder* rem);
221 
227  void removeReminder(MSMoveReminder* rem);
228 
239  virtual void activateReminders(const MSMoveReminder::Notification reason);
240 
245  return myChosenSpeedFactor;
246  }
247 
248 protected:
251  void calculateArrivalPos();
252 
253 protected:
256 
258  const MSRoute* myRoute;
259 
262 
265 
268 
269 
272 
274  typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MoveReminderCont;
275 
279 
281  std::vector<MSDevice*> myDevices;
282 
285 
288 
290  unsigned int myNumberReroutes;
291 
292 private:
293  /* @brief magic value for undeparted vehicles
294  * @note: in previous versions this was -1
295  */
297 
298 };
299 
300 #endif
301 
302 /****************************************************************************/