SUMO - Simulation of Urban MObility
MSTransportableControl.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Stores all persons or containers 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-2016 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 MSTransportableControl_h
24 #define MSTransportableControl_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>
38 #include "MSTransportable.h"
39 #include "MSVehicle.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSNet;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
60 public:
62  typedef std::vector<MSTransportable*> TransportableVector;
63 
65  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
66 
67 
68 public:
71 
72 
74  virtual ~MSTransportableControl();
75 
76 
81  bool add(MSTransportable* transportable);
82 
83 
88  MSTransportable* get(const std::string& id) const;
89 
90 
92  virtual void erase(MSTransportable* transportable);
93 
95  void setWaitEnd(SUMOTime time, MSTransportable* transportable);
96 
98  void checkWaiting(MSNet* net, const SUMOTime time);
99 
101  void addWaiting(const MSEdge* edge, MSTransportable* person);
102 
110  bool boardAnyWaiting(MSEdge* edge, MSVehicle* vehicle, MSVehicle::Stop* stop);
111 
118  bool loadAnyWaiting(MSEdge* edge, MSVehicle* vehicle, MSVehicle::Stop* stop);
119 
121  bool hasTransportables() const;
122 
124  bool hasNonWaiting() const;
125 
127  void abortWaiting();
128 
129 
136 
143 
147  constVehIt loadedBegin() const {
148  return myTransportables.begin();
149  }
150 
151 
155  constVehIt loadedEnd() const {
156  return myTransportables.end();
157  }
158 
159 
163  int size() const {
164  return (int)myTransportables.size();
165  }
166 
168  void registerJammed() {
169  myJammedNumber++;
170  }
171 
174 
178  int getLoadedNumber() const {
179  return myLoadedNumber;
180  }
181 
182 
186  int getRunningNumber() const {
187  return myRunningNumber;
188  }
189 
193  int getJammedNumber() const {
194  return myJammedNumber;
195  }
196 
198 
199 protected:
201  std::map<std::string, MSTransportable*> myTransportables;
202 
204  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
205 
207  std::map<SUMOTime, TransportableVector> myWaitingUntil;
208 
210  std::map<const MSEdge*, TransportableVector> myWaiting4Vehicle;
211 
214 
217 
220 
223 
226 
227 };
228 
229 
230 #endif
231 
232 /****************************************************************************/
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:82
long long int SUMOTime
Definition: SUMOTime.h:43
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new person.
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
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:778
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
int myLoadedNumber
The number of build transportables.
The simulated network and simulation perfomer.
Definition: MSNet.h:93
The car-following model and parameter.
Definition: MSVehicleType.h:74
virtual void erase(MSTransportable *transportable)
removes a single transportable
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
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
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.
void abortWaiting()
aborts the plan for any transportable that is still waiting for a ride
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.
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
int getJammedNumber() const
Returns the number of times a transportables was jammed.