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-2017 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 abortWaitingForVehicle();
128 
130  void abortWaiting(MSTransportable* t);
131 
138 
145 
149  constVehIt loadedBegin() const {
150  return myTransportables.begin();
151  }
152 
153 
157  constVehIt loadedEnd() const {
158  return myTransportables.end();
159  }
160 
161 
165  int size() const {
166  return (int)myTransportables.size();
167  }
168 
170  void registerJammed() {
171  myJammedNumber++;
172  }
173 
176 
180  int getLoadedNumber() const {
181  return myLoadedNumber;
182  }
183 
184 
188  int getRunningNumber() const {
189  return myRunningNumber;
190  }
191 
195  int getJammedNumber() const {
196  return myJammedNumber;
197  }
198 
200 
201 protected:
203  std::map<std::string, MSTransportable*> myTransportables;
204 
206  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
207 
209  std::map<SUMOTime, TransportableVector> myWaitingUntil;
210 
212  std::map<const MSEdge*, TransportableVector> myWaiting4Vehicle;
213 
216 
219 
222 
225 
228 
229 };
230 
231 
232 #endif
233 
234 /****************************************************************************/
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 ...
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
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.
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.
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new person.
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:820
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:89
The car-following model and parameter.
Definition: MSVehicleType.h:73
virtual void erase(MSTransportable *transportable)
removes a single transportable
void abortWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
int size() const
Returns the number of known transportables.
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
int getLoadedNumber() const
Returns the number of build transportables.
bool myHaveNewWaiting
whether a new transportable waiting for a vehicle has been added in the last step ...
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...
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, 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...
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
bool hasTransportables() const
checks whether any transportable waits to finish her plan
Structure representing possible vehicle parameter.
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occured.
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
int getJammedNumber() const
Returns the number of times a transportables was jammed.
std::vector< MSTransportable * > TransportableVector
Definition of a list of transportables.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
long long int SUMOTime
Definition: TraCIDefs.h:52
int myRunningNumber
The number of transportables within the network (build and inserted but not removed) ...
std::map< SUMOTime, TransportableVector > myWaitingUntil
the lists of walking / stopping transportables