|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The class for modelling person-movements 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef MSPerson_h 00020 #define MSPerson_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <vector> 00034 #include <set> 00035 00036 00037 // =========================================================================== 00038 // class declarations 00039 // =========================================================================== 00040 class MSNet; 00041 class MSEdge; 00042 class OutputDevice; 00043 class SUMOVehicleParameter; 00044 00045 typedef std::vector<const MSEdge*> MSEdgeVector; 00046 00047 00048 // =========================================================================== 00049 // class definitions 00050 // =========================================================================== 00056 class MSPerson { 00057 public: 00062 class MSPersonStage { 00063 public: 00065 MSPersonStage(const MSEdge& destination); 00066 00068 virtual ~MSPersonStage(); 00069 00071 const MSEdge& getDestination() const; 00072 00074 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge) = 0; 00075 00077 void setDeparted(SUMOTime now); 00078 00080 void setArrived(SUMOTime now); 00081 00083 virtual bool isWaitingFor(const std::string& line) const; 00084 00090 virtual void tripInfoOutput(OutputDevice& os) const throw(IOError) = 0; 00091 00092 00093 protected: 00095 const MSEdge& myDestination; 00096 00098 SUMOTime myDeparted; 00099 00101 SUMOTime myArrived; 00102 00103 private: 00105 MSPersonStage(const MSPersonStage&); 00106 00108 MSPersonStage& operator=(const MSPersonStage&); 00109 00110 }; 00111 00117 class MSPersonStage_Walking : public MSPersonStage { 00118 public: 00120 MSPersonStage_Walking(MSEdgeVector route, SUMOTime walkingTime, SUMOReal speed); 00121 00123 ~MSPersonStage_Walking(); 00124 00126 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00127 00133 virtual void tripInfoOutput(OutputDevice& os) const throw(IOError); 00134 00135 private: 00137 SUMOTime myWalkingTime; 00138 00139 private: 00141 MSPersonStage_Walking(const MSPersonStage_Walking&); 00142 00144 MSPersonStage_Walking& operator=(const MSPersonStage_Walking&); 00145 00146 }; 00147 00152 class MSPersonStage_Driving : public MSPersonStage { 00153 public: 00155 MSPersonStage_Driving(const MSEdge& destination, 00156 const std::vector<std::string> &lines); 00157 00159 ~MSPersonStage_Driving(); 00160 00162 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00163 00165 bool isWaitingFor(const std::string& line) const; 00166 00172 virtual void tripInfoOutput(OutputDevice& os) const throw(IOError); 00173 00174 private: 00176 const std::set<std::string> myLines; 00177 00178 private: 00180 MSPersonStage_Driving(const MSPersonStage_Driving&); 00181 00183 MSPersonStage_Driving& operator=(const MSPersonStage_Driving&); 00184 00185 }; 00186 00190 class MSPersonStage_Waiting : public MSPersonStage { 00191 public: 00193 MSPersonStage_Waiting(const MSEdge& destination, SUMOTime duration, SUMOTime until); 00194 00196 ~MSPersonStage_Waiting(); 00197 00199 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00200 00206 virtual void tripInfoOutput(OutputDevice& os) const throw(IOError); 00207 00208 private: 00210 SUMOTime myWaitingDuration; 00211 00213 SUMOTime myWaitingUntil; 00214 00215 private: 00217 MSPersonStage_Waiting(const MSPersonStage_Waiting&); 00218 00220 MSPersonStage_Waiting& operator=(const MSPersonStage_Waiting&); 00221 00222 }; 00223 00224 public: 00226 typedef std::vector<MSPersonStage*> MSPersonPlan; 00227 00228 private: 00230 const SUMOVehicleParameter* myParameter; 00231 00233 MSPersonPlan* myPlan; 00234 00236 MSPersonPlan::iterator myStep; 00237 00238 public: 00240 MSPerson(const SUMOVehicleParameter* pars, MSPersonPlan* plan); 00241 00243 ~MSPerson(); 00244 00246 const std::string& getID() const throw(); 00247 00249 void proceed(MSNet* net, SUMOTime time); 00250 00252 SUMOTime getDesiredDepart() const throw(); 00253 00255 void setDeparted(SUMOTime now); 00256 00258 const MSEdge& getDestination() const; 00259 00265 void tripInfoOutput(OutputDevice& os) const throw(IOError); 00266 00268 bool isWaitingFor(const std::string& line) const; 00269 00270 private: 00272 MSPerson(const MSPerson&); 00273 00275 MSPerson& operator=(const MSPerson&); 00276 00277 }; 00278 00279 00280 #endif 00281 00282 /****************************************************************************/