MSVehicleControl.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSVehicleControl_h
00020 #define MSVehicleControl_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <map>
00034 #include <set>
00035 #include <utils/common/SUMOTime.h>
00036 #include <utils/common/RandomDistributor.h>
00037 #include <utils/common/SUMOVehicleParameter.h>
00038
00039
00040
00041
00042
00043 class MSVehicle;
00044 class MSRoute;
00045 class MSVehicleType;
00046 class BinaryInputDevice;
00047 class MSEdge;
00048
00049
00050
00051
00052
00068 class MSVehicleControl {
00069 public:
00071 typedef std::map<std::string, MSVehicle*>::const_iterator constVehIt;
00072
00073 public:
00075 MSVehicleControl() throw();
00076
00077
00079 virtual ~MSVehicleControl() throw();
00080
00081
00084
00098 virtual MSVehicle *buildVehicle(SUMOVehicleParameter* defs, const MSRoute* route,
00099 const MSVehicleType* type) throw(ProcessError);
00101
00102
00103
00106
00119 virtual bool addVehicle(const std::string &id, MSVehicle *v) throw();
00120
00121
00130 virtual MSVehicle *getVehicle(const std::string &id) const throw();
00131
00132
00138 virtual void deleteVehicle(MSVehicle *v) throw();
00139
00140
00152 void scheduleVehicleRemoval(MSVehicle *v) throw();
00153
00154
00159 constVehIt loadedVehBegin() const throw();
00160
00161
00166 constVehIt loadedVehEnd() const throw();
00168
00169
00170
00173
00182 virtual void vehicleEmitted(const MSVehicle &v) throw();
00184
00185
00186
00189
00193 unsigned int getLoadedVehicleNo() const throw() {
00194 return myLoadedVehNo;
00195 }
00196
00197
00201 unsigned int getEndedVehicleNo() const throw() {
00202 return myEndedVehNo;
00203 }
00204
00205
00209 unsigned int getRunningVehicleNo() const throw() {
00210 return myRunningVehNo;
00211 }
00212
00213
00217 unsigned int getEmittedVehicleNo() const throw() {
00218 return myRunningVehNo + myEndedVehNo;
00219 }
00220
00221
00225 bool haveAllVehiclesQuit() const throw() {
00226 return myLoadedVehNo==myEndedVehNo;
00227 }
00229
00230
00231
00234
00244 SUMOReal getMeanWaitingTime() const throw();
00245
00246
00256 SUMOReal getMeanTravelTime() const throw();
00258
00259
00260
00261
00264
00277 bool addVType(MSVehicleType* vehType) throw();
00278
00279
00293 bool addVTypeDistribution(const std::string &id, RandomDistributor<MSVehicleType*> *vehTypeDistribution) throw();
00294
00295
00303 bool hasVTypeDistribution(const std::string &id) const throw();
00304
00305
00310 MSVehicleType *getVType(const std::string &id=DEFAULT_VTYPE_ID) throw();
00311
00312
00316 void insertVTypeIDs(std::vector<std::string> &into) const throw();
00318
00319 void addWaiting(const MSEdge* const edge, MSVehicle *vehicle) throw();
00320
00321 void removeWaiting(const MSEdge* const edge, MSVehicle *vehicle) throw();
00322
00323 MSVehicle *getWaitingVehicle(const MSEdge* const edge, const std::set<std::string> &lines) throw();
00324
00325
00326 #ifdef HAVE_MESOSIM
00329
00330
00333 void saveState(std::ostream &os) throw();
00334
00338 void loadState(BinaryInputDevice &bis) throw();
00340 #endif
00341
00342
00343 private:
00350 bool checkVType(const std::string &id) throw();
00351
00352
00353 protected:
00356
00358 unsigned int myLoadedVehNo;
00359
00361 unsigned int myRunningVehNo;
00362
00364 unsigned int myEndedVehNo;
00366
00367
00370
00372 SUMOTime myAbsVehWaitingTime;
00373
00375 SUMOTime myAbsVehTravelTime;
00377
00378
00381
00383 typedef std::map< std::string, MSVehicle* > VehicleDictType;
00385 VehicleDictType myVehicleDict;
00387
00388
00391
00393 typedef std::map< std::string, MSVehicleType* > VTypeDictType;
00395 VTypeDictType myVTypeDict;
00396
00398 typedef std::map< std::string, RandomDistributor<MSVehicleType*>* > VTypeDistDictType;
00400 VTypeDistDictType myVTypeDistDict;
00401
00403 bool myDefaultVTypeMayBeDeleted;
00404
00406 std::map<const MSEdge* const, std::vector<MSVehicle*> > myWaiting;
00407
00408
00409 private:
00411 MSVehicleControl(const MSVehicleControl &s);
00412
00414 MSVehicleControl &operator=(const MSVehicleControl &s);
00415
00416
00417 };
00418
00419
00420 #endif
00421
00422
00423