SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSVehicleControl.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // The class responsible for building and deletion of vehicles
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 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 MSVehicleControl_h
23 #define MSVehicleControl_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 <math.h>
36 #include <string>
37 #include <map>
38 #include <set>
39 #include "MSGlobals.h"
40 #include <utils/common/SUMOTime.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class SUMOVehicle;
49 class MSVehicle;
50 class MSRoute;
51 class MSVehicleType;
52 class BinaryInputDevice;
53 class MSEdge;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
75 public:
77  typedef std::map<std::string, SUMOVehicle*>::const_iterator constVehIt;
78 
79 public:
82 
83 
85  virtual ~MSVehicleControl() ;
86 
87 
90 
104  virtual SUMOVehicle* buildVehicle(SUMOVehicleParameter* defs, const MSRoute* route,
105  const MSVehicleType* type) ;
107 
108 
109 
112 
125  virtual bool addVehicle(const std::string& id, SUMOVehicle* v) ;
126 
127 
136  SUMOVehicle* getVehicle(const std::string& id) const ;
137 
138 
145  virtual void deleteVehicle(SUMOVehicle* v, bool discard=false) ;
146 
147 
160 
161 
166  constVehIt loadedVehBegin() const ;
167 
168 
173  constVehIt loadedVehEnd() const ;
175 
176 
177 
180 
188  void vehicleDeparted(const SUMOVehicle& v) ;
190 
191 
192 
195 
199  unsigned int getLoadedVehicleNo() const {
200  return myLoadedVehNo;
201  }
202 
203 
207  unsigned int getEndedVehicleNo() const {
208  return myEndedVehNo;
209  }
210 
211 
215  unsigned int getRunningVehicleNo() const {
216  return myRunningVehNo;
217  }
218 
219 
223  unsigned int getDepartedVehicleNo() const {
225  }
226 
227 
232  bool isInQuota(const SUMOReal frac) const;
233 
234 
239  int getActiveVehicleCount() const {
241  }
243 
244 
247 
252  void printMeanWaitingTime(OutputDevice& od) const ;
253 
254 
259  void printMeanTravelTime(OutputDevice& od) const ;
261 
262 
263 
264 
267 
280  bool addVType(MSVehicleType* vehType) ;
281 
282 
296  bool addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*> *vehTypeDistribution) ;
297 
298 
306  bool hasVTypeDistribution(const std::string& id) const ;
307 
308 
313  MSVehicleType* getVType(const std::string& id = DEFAULT_VTYPE_ID) ;
314 
315 
319  void insertVTypeIDs(std::vector<std::string> &into) const ;
321 
322  void addWaiting(const MSEdge* const edge, SUMOVehicle* vehicle) ;
323 
324  void removeWaiting(const MSEdge* const edge, SUMOVehicle* vehicle) ;
325 
326  SUMOVehicle* getWaitingVehicle(const MSEdge* const edge, const std::set<std::string> &lines) ;
327 
332  }
333 
338  }
339 
342 
346  virtual void saveState(std::ostream& os) ;
347 
351  virtual void loadState(BinaryInputDevice& bis, const SUMOTime offset) ;
353  //
354 
357  void abortWaiting() ;
358 
359 
360 private:
367  bool checkVType(const std::string& id) ;
368 
369 
370 protected:
373 
375  unsigned int myLoadedVehNo;
376 
378  unsigned int myRunningVehNo;
379 
381  unsigned int myEndedVehNo;
382 
384  unsigned int myDiscarded;
386 
387 
390 
393 
397 
398 
401 
403  typedef std::map< std::string, SUMOVehicle* > VehicleDictType;
407 
408 
411 
413  typedef std::map< std::string, MSVehicleType* > VTypeDictType;
416 
418  typedef std::map< std::string, RandomDistributor<MSVehicleType*>* > VTypeDistDictType;
421 
424 
426  std::map<const MSEdge* const, std::vector<SUMOVehicle*> > myWaiting;
427 
429  unsigned int myWaitingForPerson;
430 
431 
432 private:
435 
438 
439 
440 };
441 
442 
443 #endif
444 
445 /****************************************************************************/
446