SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSBusStop.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A lane area vehicles can halt at
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSBusStop_h
21 #define MSBusStop_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <algorithm>
35 #include <map>
36 #include <string>
37 #include <utils/common/Named.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSLane;
44 class SUMOVehicle;
45 class MSPerson;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
63 class MSBusStop : public Named {
64 public:
74  MSBusStop(const std::string& id,
75  const std::vector<std::string>& lines, MSLane& lane,
76  SUMOReal begPos, SUMOReal endPos);
77 
78 
80  virtual ~MSBusStop();
81 
82 
87  const MSLane& getLane() const;
88 
89 
95 
96 
102 
103 
115  void enter(SUMOVehicle* what, SUMOReal beg, SUMOReal end);
116 
117 
127  void leaveFrom(SUMOVehicle* what);
128 
129 
134  SUMOReal getLastFreePos(const SUMOVehicle& forVehicle) const;
135 
136 
139  unsigned int getPersonNumber() const {
140  return static_cast<unsigned int>(myWaitingPersons.size());
141  }
142 
143  void addPerson(MSPerson* p) {
144  myWaitingPersons.push_back(p);
145  }
146 
148  std::vector<MSPerson*>::iterator i = std::find(myWaitingPersons.begin(), myWaitingPersons.end(), p);
149  if (i != myWaitingPersons.end()) {
150  myWaitingPersons.erase(i);
151  }
152  }
153 
154 protected:
161  void computeLastFreePos();
162 
163 
164 protected:
166  std::vector<std::string> myLines;
167 
169  std::map<SUMOVehicle*, std::pair<SUMOReal, SUMOReal> > myEndPositions;
170 
173 
176 
179 
182 
184  std::vector<MSPerson*> myWaitingPersons;
185 
186 
187 private:
189  MSBusStop(const MSBusStop&);
190 
192  MSBusStop& operator=(const MSBusStop&);
193 
194 
195 };
196 
197 
198 #endif
199 
200 /****************************************************************************/
201 
void removePerson(MSPerson *p)
Definition: MSBusStop.h:147
MSBusStop & operator=(const MSBusStop &)
Invalidated assignment operator.
SUMOReal myEndPos
The end position this bus stop is located at.
Definition: MSBusStop.h:178
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Definition: MSBusStop.h:166
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
Definition: MSBusStop.cpp:71
SUMOReal getBeginLanePosition() const
Returns the begin position of this bus stop.
Definition: MSBusStop.cpp:65
const MSLane & getLane() const
Returns the lane this bus stop is located at.
Definition: MSBusStop.cpp:59
void computeLastFreePos()
Computes the last free position on this stop.
Definition: MSBusStop.cpp:101
void enter(SUMOVehicle *what, SUMOReal beg, SUMOReal end)
Called if a vehicle enters this stop.
Definition: MSBusStop.cpp:77
Representation of a vehicle.
Definition: SUMOVehicle.h:63
MSLane & myLane
The lane this bus stop is located at.
Definition: MSBusStop.h:172
A lane area vehicles can halt at.
Definition: MSBusStop.h:63
std::vector< MSPerson * > myWaitingPersons
Persons waiting at this stop.
Definition: MSBusStop.h:184
void addPerson(MSPerson *p)
Definition: MSBusStop.h:143
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
Definition: MSBusStop.cpp:93
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:84
MSBusStop(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, SUMOReal begPos, SUMOReal endPos)
Constructor.
Definition: MSBusStop.cpp:45
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:169
SUMOReal myBegPos
The begin position this bus stop is located at.
Definition: MSBusStop.h:175
virtual ~MSBusStop()
Destructor.
Definition: MSBusStop.cpp:55
#define SUMOReal
Definition: config.h:215
unsigned int getPersonNumber() const
Returns the number of persons waiting on this stop.
Definition: MSBusStop.h:139
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:181