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-sim.org/
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>
36 #include <set>
38 #include <utils/common/StdDefs.h>
39 #include "MSRoute.h"
40 #include "MSMoveReminder.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
47 class MSVehicleType;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
57 class MSBaseVehicle : public SUMOVehicle {
58 public:
66  MSBaseVehicle(SUMOVehicleParameter* pars, const MSRoute* route, const MSVehicleType* type, const SUMOReal speedFactor);
67 
68 
70  virtual ~MSBaseVehicle();
71 
72 
74  const std::string& getID() const;
75 
80  const SUMOVehicleParameter& getParameter() const;
81 
82 
86  inline const MSRoute& getRoute() const {
87  return *myRoute;
88  }
89 
90 
94  inline const MSVehicleType& getVehicleType() const {
95  return *myType;
96  }
97 
98 
102  SUMOReal getMaxSpeed() const;
103 
104 
112  const MSEdge* succEdge(unsigned int nSuccs) const;
113 
118  const MSEdge* getEdge() const;
119 
120 
124  virtual bool isOnRoad() const {
125  return true;
126  }
127 
128 
138  void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, bool withTaz = false);
139 
140 
151  bool replaceRouteEdges(const MSEdgeVector& edges, bool onInit = false);
152 
153 
159  virtual SUMOReal getAcceleration() const;
160 
166  void onDepart();
167 
171  inline SUMOTime getDeparture() const {
172  return myDeparture;
173  }
174 
179  virtual SUMOReal getArrivalPos() const {
180  return myArrivalPos;
181  }
182 
185  bool hasDeparted() const;
186 
190  virtual bool hasArrived() const;
191 
195  inline unsigned int getNumberReroutes() const {
196  return myNumberReroutes;
197  }
198 
202  inline const std::vector<MSDevice*>& getDevices() const {
203  return myDevices;
204  }
205 
212  virtual void addPerson(MSPerson* person);
213 
218  bool hasValidRoute(std::string& msg) const;
219 
225  void addReminder(MSMoveReminder* rem);
226 
232  void removeReminder(MSMoveReminder* rem);
233 
244  virtual void activateReminders(const MSMoveReminder::Notification reason);
245 
250  return myChosenSpeedFactor;
251  }
252 
254  MSDevice* getDevice(const std::type_info& type) const;
255 
256 
258 
259 
261  virtual void saveState(OutputDevice& out);
262 
264 
265 protected:
268  void calculateArrivalPos();
269 
270 protected:
273 
275  const MSRoute* myRoute;
276 
279 
282 
285 
286 
289 
291  typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MoveReminderCont;
292 
296 
298  std::vector<MSDevice*> myDevices;
299 
302 
305 
307  unsigned int myNumberReroutes;
308 
309 private:
310  /* @brief magic value for undeparted vehicles
311  * @note: in previous versions this was -1
312  */
314 
317 
318 
319 #ifdef _DEBUG
320 public:
321  static void initMoveReminderOutput(const OptionsCont& oc);
322 
323 protected:
325  void traceMoveReminder(const std::string& type, MSMoveReminder* rem, SUMOReal pos, bool keep) const;
326 
328  const bool myTraceMoveReminders;
329 private:
331  static std::set<std::string> myShallTraceMoveReminders;
332 #endif
333 
334 
335 };
336 
337 #endif
338 
339 /****************************************************************************/