SUMO - Simulation of Urban MObility
MSBusStop.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A lane area vehicles can halt at
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2005-2014 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSBusStop_h
22 #define MSBusStop_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <algorithm>
36 #include <map>
37 #include <string>
38 #include <utils/common/Named.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MSLane;
45 class SUMOVehicle;
46 class MSPerson;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
64 class MSBusStop : public Named {
65 public:
75  MSBusStop(const std::string& id,
76  const std::vector<std::string>& lines, MSLane& lane,
77  SUMOReal begPos, SUMOReal endPos);
78 
79 
81  virtual ~MSBusStop();
82 
83 
88  const MSLane& getLane() const;
89 
90 
96 
97 
103 
104 
116  void enter(SUMOVehicle* what, SUMOReal beg, SUMOReal end);
117 
118 
128  void leaveFrom(SUMOVehicle* what);
129 
130 
135  SUMOReal getLastFreePos(const SUMOVehicle& forVehicle) const;
136 
137 
140  unsigned int getPersonNumber() const {
141  return static_cast<unsigned int>(myWaitingPersons.size());
142  }
143 
144  void addPerson(MSPerson* p) {
145  myWaitingPersons.push_back(p);
146  }
147 
149  std::vector<MSPerson*>::iterator i = std::find(myWaitingPersons.begin(), myWaitingPersons.end(), p);
150  if (i != myWaitingPersons.end()) {
151  myWaitingPersons.erase(i);
152  }
153  }
154 
155 protected:
162  void computeLastFreePos();
163 
164 
165 protected:
167  std::vector<std::string> myLines;
168 
170  std::map<SUMOVehicle*, std::pair<SUMOReal, SUMOReal> > myEndPositions;
171 
174 
177 
180 
183 
185  std::vector<MSPerson*> myWaitingPersons;
186 
187 
188 private:
190  MSBusStop(const MSBusStop&);
191 
193  MSBusStop& operator=(const MSBusStop&);
194 
195 
196 };
197 
198 
199 #endif
200 
201 /****************************************************************************/
202 
void removePerson(MSPerson *p)
Definition: MSBusStop.h:148
MSBusStop & operator=(const MSBusStop &)
Invalidated assignment operator.
SUMOReal myEndPos
The end position this bus stop is located at.
Definition: MSBusStop.h:179
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Definition: MSBusStop.h:167
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
Definition: MSBusStop.cpp:72
SUMOReal getBeginLanePosition() const
Returns the begin position of this bus stop.
Definition: MSBusStop.cpp:66
const MSLane & getLane() const
Returns the lane this bus stop is located at.
Definition: MSBusStop.cpp:60
void computeLastFreePos()
Computes the last free position on this stop.
Definition: MSBusStop.cpp:102
void enter(SUMOVehicle *what, SUMOReal beg, SUMOReal end)
Called if a vehicle enters this stop.
Definition: MSBusStop.cpp:78
Representation of a vehicle.
Definition: SUMOVehicle.h:64
MSLane & myLane
The lane this bus stop is located at.
Definition: MSBusStop.h:173
A lane area vehicles can halt at.
Definition: MSBusStop.h:64
std::vector< MSPerson * > myWaitingPersons
Persons waiting at this stop.
Definition: MSBusStop.h:185
void addPerson(MSPerson *p)
Definition: MSBusStop.h:144
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
Definition: MSBusStop.cpp:94
Base class for objects which have an id.
Definition: Named.h:45
SUMOReal getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
Definition: MSBusStop.cpp:85
MSBusStop(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, SUMOReal begPos, SUMOReal endPos)
Constructor.
Definition: MSBusStop.cpp:46
std::map< SUMOVehicle *, std::pair< SUMOReal, SUMOReal > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
Definition: MSBusStop.h:170
SUMOReal myBegPos
The begin position this bus stop is located at.
Definition: MSBusStop.h:176
virtual ~MSBusStop()
Destructor.
Definition: MSBusStop.cpp:56
#define SUMOReal
Definition: config.h:215
unsigned int getPersonNumber() const
Returns the number of persons waiting on this stop.
Definition: MSBusStop.h:140
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
SUMOReal myLastFreePos
The last free position at this stop (variable)
Definition: MSBusStop.h:182