SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDevice_Vehroutes.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A device which collects info on the vehicle trip
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2009-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 MSDevice_Vehroutes_h
23 #define MSDevice_Vehroutes_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 "MSDevice.h"
36 #include <microsim/MSNet.h>
37 #include <utils/common/SUMOTime.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSEdge;
44 class MSRoute;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
58 class MSDevice_Vehroutes : public MSDevice {
59 public:
62  static void init();
63 
64 
75  static MSDevice_Vehroutes* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into, unsigned int maxRoutes = INT_MAX);
76 
77 
79  static void generateOutputForUnfinished();
80 
81 
82 
83 public:
86 
87 
88 
91 
101 
102 
114  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason);
116 
117 
124  void generateOutput() const;
125 
126 
132  const MSRoute* getRoute(int index) const;
133 
134 
135 
136 private:
142  MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, unsigned int maxRoutes);
143 
144 
150  void writeXMLRoute(OutputDevice& os, int index = -1) const;
151 
152 
155  void addRoute();
156 
157 
158 
159 private:
161  static bool mySaveExits;
162 
164  static bool myLastRouteOnly;
165 
167  static bool mySorted;
168 
170  static bool myWithTaz;
171 
172 
177  public:
180 
185  void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to);
186 
188  std::map<const SUMOVehicle*, MSDevice_Vehroutes*, Named::NamedLikeComparatorIdLess<SUMOVehicle> > myDevices;
189 
190  };
191 
192 
195 
197  static std::map<const SUMOTime, int> myDepartureCounts;
198 
200  static std::map<const SUMOTime, std::string> myRouteInfos;
201 
202 
213  public:
219  RouteReplaceInfo(const MSEdge* const edge_, const SUMOTime time_, const MSRoute* const route_)
220  : edge(edge_), time(time_), route(route_) {}
221 
224 
226  const MSEdge* edge;
227 
230 
232  const MSRoute* route;
233 
234  };
235 
238 
240  std::vector<RouteReplaceInfo> myReplacedRoutes;
241 
243  std::vector<SUMOTime> myExits;
244 
246  const unsigned int myMaxRoutes;
247 
250 
251 
252 private:
255 
258 
259 
260 };
261 
262 
263 #endif
264 
265 /****************************************************************************/
266