SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // The class for modelling person-movements 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSPerson_h 00024 #define MSPerson_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <string> 00037 #include <vector> 00038 #include <set> 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class MSNet; 00045 class MSEdge; 00046 class OutputDevice; 00047 class SUMOVehicleParameter; 00048 00049 typedef std::vector<const MSEdge*> MSEdgeVector; 00050 00051 00052 // =========================================================================== 00053 // class definitions 00054 // =========================================================================== 00060 class MSPerson { 00061 public: 00066 class MSPersonStage { 00067 public: 00069 MSPersonStage(const MSEdge& destination); 00070 00072 virtual ~MSPersonStage(); 00073 00075 const MSEdge& getDestination() const; 00076 00078 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge) = 0; 00079 00081 void setDeparted(SUMOTime now); 00082 00084 void setArrived(SUMOTime now); 00085 00087 virtual bool isWaitingFor(const std::string& line) const; 00088 00094 virtual void tripInfoOutput(OutputDevice& os) const = 0; 00095 00096 00097 protected: 00099 const MSEdge& myDestination; 00100 00102 SUMOTime myDeparted; 00103 00105 SUMOTime myArrived; 00106 00107 private: 00109 MSPersonStage(const MSPersonStage&); 00110 00112 MSPersonStage& operator=(const MSPersonStage&); 00113 00114 }; 00115 00121 class MSPersonStage_Walking : public MSPersonStage { 00122 public: 00124 MSPersonStage_Walking(MSEdgeVector route, SUMOTime walkingTime, SUMOReal speed); 00125 00127 ~MSPersonStage_Walking(); 00128 00130 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00131 00137 virtual void tripInfoOutput(OutputDevice& os) const; 00138 00139 private: 00141 SUMOTime myWalkingTime; 00142 00143 private: 00145 MSPersonStage_Walking(const MSPersonStage_Walking&); 00146 00148 MSPersonStage_Walking& operator=(const MSPersonStage_Walking&); 00149 00150 }; 00151 00156 class MSPersonStage_Driving : public MSPersonStage { 00157 public: 00159 MSPersonStage_Driving(const MSEdge& destination, 00160 const std::vector<std::string> &lines); 00161 00163 ~MSPersonStage_Driving(); 00164 00166 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00167 00169 bool isWaitingFor(const std::string& line) const; 00170 00176 virtual void tripInfoOutput(OutputDevice& os) const; 00177 00178 private: 00180 const std::set<std::string> myLines; 00181 00182 private: 00184 MSPersonStage_Driving(const MSPersonStage_Driving&); 00185 00187 MSPersonStage_Driving& operator=(const MSPersonStage_Driving&); 00188 00189 }; 00190 00194 class MSPersonStage_Waiting : public MSPersonStage { 00195 public: 00197 MSPersonStage_Waiting(const MSEdge& destination, SUMOTime duration, SUMOTime until); 00198 00200 ~MSPersonStage_Waiting(); 00201 00203 virtual void proceed(MSNet* net, MSPerson* person, SUMOTime now, const MSEdge& previousEdge); 00204 00210 virtual void tripInfoOutput(OutputDevice& os) const; 00211 00212 private: 00214 SUMOTime myWaitingDuration; 00215 00217 SUMOTime myWaitingUntil; 00218 00219 private: 00221 MSPersonStage_Waiting(const MSPersonStage_Waiting&); 00222 00224 MSPersonStage_Waiting& operator=(const MSPersonStage_Waiting&); 00225 00226 }; 00227 00228 public: 00230 typedef std::vector<MSPersonStage*> MSPersonPlan; 00231 00232 private: 00234 const SUMOVehicleParameter* myParameter; 00235 00237 MSPersonPlan* myPlan; 00238 00240 MSPersonPlan::iterator myStep; 00241 00242 public: 00244 MSPerson(const SUMOVehicleParameter* pars, MSPersonPlan* plan); 00245 00247 ~MSPerson(); 00248 00250 const std::string& getID() const ; 00251 00253 void proceed(MSNet* net, SUMOTime time); 00254 00256 SUMOTime getDesiredDepart() const ; 00257 00259 void setDeparted(SUMOTime now); 00260 00262 const MSEdge& getDestination() const; 00263 00269 void tripInfoOutput(OutputDevice& os) const; 00270 00272 bool isWaitingFor(const std::string& line) const; 00273 00274 private: 00276 MSPerson(const MSPerson&); 00277 00279 MSPerson& operator=(const MSPerson&); 00280 00281 }; 00282 00283 00284 #endif 00285 00286 /****************************************************************************/