SUMO - Simulation of Urban MObility
MSTransportableControl.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Stores all persons or containers in the net and handles their waiting for cars.
21 /****************************************************************************/
22 #ifndef MSTransportableControl_h
23 #define MSTransportableControl_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 <vector>
36 #include <map>
37 #include "MSTransportable.h"
38 #include "MSVehicle.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MSNet;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
59 public:
61  typedef std::vector<MSTransportable*> TransportableVector;
62 
64  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
65 
66 
67 public:
70 
71 
73  virtual ~MSTransportableControl();
74 
75 
80  bool add(MSTransportable* transportable);
81 
82 
87  MSTransportable* get(const std::string& id) const;
88 
89 
91  virtual void erase(MSTransportable* transportable);
92 
94  void setWaitEnd(SUMOTime time, MSTransportable* transportable);
95 
97  void checkWaiting(MSNet* net, const SUMOTime time);
98 
100  void addWaiting(const MSEdge* edge, MSTransportable* person);
101 
109  bool boardAnyWaiting(MSEdge* edge, MSVehicle* vehicle, MSVehicle::Stop* stop);
110 
117  bool loadAnyWaiting(MSEdge* edge, MSVehicle* vehicle, MSVehicle::Stop* stop);
118 
120  bool hasTransportables() const;
121 
123  bool hasNonWaiting() const;
124 
126  void abortWaitingForVehicle();
127 
129  void abortWaiting(MSTransportable* t);
130 
138  std::mt19937* rng) const;
139 
146 
150  constVehIt loadedBegin() const {
151  return myTransportables.begin();
152  }
153 
154 
158  constVehIt loadedEnd() const {
159  return myTransportables.end();
160  }
161 
162 
166  int size() const {
167  return (int)myTransportables.size();
168  }
169 
171  void registerJammed() {
172  myJammedNumber++;
173  }
174 
177 
181  int getLoadedNumber() const {
182  return myLoadedNumber;
183  }
184 
185 
189  int getRunningNumber() const {
190  return myRunningNumber;
191  }
192 
196  int getJammedNumber() const {
197  return myJammedNumber;
198  }
199 
201 
202 protected:
204  std::map<std::string, MSTransportable*> myTransportables;
205 
207  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
208 
210  std::map<SUMOTime, TransportableVector> myWaitingUntil;
211 
213  std::map<const MSEdge*, TransportableVector> myWaiting4Vehicle;
214 
217 
220 
223 
226 
229 
230 };
231 
232 
233 #endif
234 
235 /****************************************************************************/
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge ...
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
int getLoadedNumber() const
Returns the number of build transportables.
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
void registerJammed()
register a jammed transportable
virtual ~MSTransportableControl()
Destructor.
int size() const
Returns the number of known transportables.
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
int myLoadedNumber
The number of build transportables.
The simulated network and simulation perfomer.
Definition: MSNet.h:90
The car-following model and parameter.
Definition: MSVehicleType.h:72
virtual void erase(MSTransportable *transportable)
removes a single transportable
void abortWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
A road/street connecting two junctions.
Definition: MSEdge.h:80
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
bool myHaveNewWaiting
whether a new transportable waiting for a vehicle has been added in the last step ...
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
bool loadAnyWaiting(MSEdge *edge, MSVehicle *vehicle, MSVehicle::Stop *stop)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
bool hasTransportables() const
checks whether any transportable waits to finish her plan
int myJammedNumber
The number of jammed transportables.
int myWaitingForVehicleNumber
The number of transportables waiting for vehicles.
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...
Structure representing possible vehicle parameter.
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occured.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
std::vector< MSTransportable * > TransportableVector
Definition of a list of transportables.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
long long int SUMOTime
Definition: TraCIDefs.h:51
int myRunningNumber
The number of transportables within the network (build and inserted but not removed) ...
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
std::map< SUMOTime, TransportableVector > myWaitingUntil
the lists of walking / stopping transportables
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:901
int getJammedNumber() const
Returns the number of times a transportables was jammed.