SUMO - Simulation of Urban MObility
MSPersonControl.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Stores all persons in the net and handles their waiting for cars.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSPersonControl_h
24 #define MSPersonControl_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <map>
39 #include "MSVehicle.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSNet;
46 class MSVehicle;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
60 public:
62  typedef std::vector<MSTransportable*> PersonVector;
63 
65  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
66 
67 
68 public:
71 
72 
74  virtual ~MSPersonControl();
75 
76 
82  bool add(const std::string& id, MSPerson* person);
83 
84 
89  MSTransportable* get(const std::string& id) const;
90 
91 
93  virtual void erase(MSTransportable* person);
94 
96  void setDeparture(SUMOTime time, MSPerson* person);
97 
99  void setWaitEnd(SUMOTime time, MSTransportable* person);
100 
102  void checkWaitingPersons(MSNet* net, const SUMOTime time);
103 
105  void addWaiting(const MSEdge* edge, MSTransportable* person);
106 
114  bool boardAnyWaiting(MSEdge* edge, MSVehicle* vehicle, MSVehicle::Stop* stop);
115 
117  bool hasPersons() const;
118 
120  bool hasNonWaiting() const;
121 
123  void abortWaiting();
124 
125 
131  virtual MSPerson* buildPerson(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan) const;
132 
133  void setWalking(MSTransportable* p);
134  void unsetWalking(MSTransportable* p);
135 
137  bool isWaiting4Vehicle(const MSEdge* const edge, MSPerson* p) const;
138 
139 
143  constVehIt loadedPersonsBegin() const {
144  return myPersons.begin();
145  }
146 
147 
151  constVehIt loadedPersonsEnd() const {
152  return myPersons.end();
153  }
154 
155 
159  unsigned int size() const {
160  return (unsigned int) myPersons.size();
161  }
162 
164  void registerJammed() {
166  }
167 
170 
174  unsigned int getLoadedPersonNumber() const {
175  return myLoadedPersonNumber;
176  }
177 
178 
182  unsigned int getRunningPersonNumber() const {
183  return myRunningPersonNumber;
184  }
185 
189  unsigned int getJammedPersonNumber() const {
190  return myJammedPersonNumber;
191  }
192 
194 
195 protected:
197  std::map<std::string, MSTransportable*> myPersons;
198 
200  std::map<std::string, MSTransportable*> myWalking;
201 
203  std::map<SUMOTime, PersonVector> myWaiting4Departure;
204 
206  std::map<SUMOTime, PersonVector> myWaitingUntil;
207 
209  std::map<const MSEdge*, PersonVector> myWaiting4Vehicle;
210 
212  unsigned int myLoadedPersonNumber;
213 
215  unsigned int myRunningPersonNumber;
216 
218  unsigned int myJammedPersonNumber;
219 
220 };
221 
222 
223 #endif
224 
225 /****************************************************************************/
unsigned int getLoadedPersonNumber() const
Returns the number of build Persons.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:43
virtual void erase(MSTransportable *person)
removes a single person
virtual MSPerson * buildPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new person.
std::map< SUMOTime, PersonVector > myWaiting4Departure
Persons waiting for departure.
unsigned int myRunningPersonNumber
The number of persons within the network (build and inserted but not removed)
constVehIt loadedPersonsEnd() const
Returns the end of the internal persons map.
unsigned int getJammedPersonNumber() const
Returns the number of times a person was jammed.
unsigned int getRunningPersonNumber() const
Returns the number of build and inserted, but not yet deleted Persons.
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:564
void setWalking(MSTransportable *p)
MSPersonControl()
Constructor.
unsigned int myJammedPersonNumber
The number of jammed persons.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
The car-following model and parameter.
Definition: MSVehicleType.h:74
void setWaitEnd(SUMOTime time, MSTransportable *person)
sets the arrival time for a waiting or walking person
bool hasPersons() const
checks whether any person waits to finish her plan
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
bool add(const std::string &id, MSPerson *person)
Adds a single person, returns false if an id clash occured.
void abortWaiting()
aborts the plan for any person that is still waiting for a ride
void checkWaitingPersons(MSNet *net, const SUMOTime time)
checks whether any persons waiting or walking time is over
std::map< std::string, MSTransportable * > myWalking
all persons by id
unsigned int size() const
Returns the number of known persons.
std::map< const MSEdge *, PersonVector > myWaiting4Vehicle
the lists of waiting persons
std::map< std::string, MSTransportable * > myPersons
all persons by id
void unsetWalking(MSTransportable *p)
bool hasNonWaiting() const
checks whether any person is still engaged in walking / stopping
void registerJammed()
register a jammed person
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a person to the list of persons waiting for a vehicle on the specified edge
unsigned int myLoadedPersonNumber
The number of build persons.
Structure representing possible vehicle parameter.
std::map< SUMOTime, PersonVector > myWaitingUntil
the lists of walking / stopping persons
void setDeparture(SUMOTime time, MSPerson *person)
sets the arrival time for a waiting or walking person
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal persons map iterator.
std::vector< MSTransportable * > PersonVector
Definition of a list of persons.
virtual ~MSPersonControl()
Destructor.
bool boardAnyWaiting(MSEdge *edge, MSVehicle *vehicle, MSVehicle::Stop *stop)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
bool isWaiting4Vehicle(const MSEdge *const edge, MSPerson *p) const
returns whether the the given person is waiting for a vehicle on the given edge
constVehIt loadedPersonsBegin() const
Returns the begin of the internal persons map.