SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSStoppingPlace.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.dlr.de/
11 // Copyright (C) 2005-2015 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 MSStoppingPlace_h
22 #define MSStoppingPlace_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 MSTransportable;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
64 class MSStoppingPlace : public Named {
65 public:
75  MSStoppingPlace(const std::string& id,
76  const std::vector<std::string>& lines, MSLane& lane,
77  SUMOReal begPos, SUMOReal endPos);
78 
79 
81  virtual ~MSStoppingPlace();
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 getTransportableNumber() const {
141  return static_cast<unsigned int>(myWaitingTransportables.size());
142  }
143 
146  myWaitingTransportables.push_back(p);
147  }
148 
151  std::vector<MSTransportable*>::iterator i = std::find(myWaitingTransportables.begin(), myWaitingTransportables.end(), p);
152  if (i != myWaitingTransportables.end()) {
153  myWaitingTransportables.erase(i);
154  }
155  }
156 
157 protected:
164  void computeLastFreePos();
165 
166 
167 protected:
169  std::vector<std::string> myLines;
170 
172  std::map<SUMOVehicle*, std::pair<SUMOReal, SUMOReal> > myEndPositions;
173 
176 
179 
182 
185 
187  std::vector<MSTransportable*> myWaitingTransportables;
188 
189 
190 private:
193 
196 
197 
198 };
199 
200 
201 #endif
202 
203 /****************************************************************************/
204 
unsigned int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
std::vector< MSTransportable * > myWaitingTransportables
Persons waiting at this stop.
A lane area vehicles can halt at.
SUMOReal getEndLanePosition() const
Returns the end position of this stop.
void addTransportable(MSTransportable *p)
adds a transportable to this stop
virtual ~MSStoppingPlace()
Destructor.
const MSLane & getLane() const
Returns the lane this stop is located at.
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
SUMOReal myEndPos
The end position this bus stop is located at.
SUMOReal getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
SUMOReal myBegPos
The begin position this bus stop is located at.
MSLane & myLane
The lane this bus stop is located at.
MSStoppingPlace(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, SUMOReal begPos, SUMOReal endPos)
Constructor.
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
Base class for objects which have an id.
Definition: Named.h:45
void enter(SUMOVehicle *what, SUMOReal beg, SUMOReal end)
Called if a vehicle enters this stop.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
SUMOReal myLastFreePos
The last free position at this stop (variable)
SUMOReal getBeginLanePosition() const
Returns the begin position of this stop.
void computeLastFreePos()
Computes the last free position on this stop.
#define SUMOReal
Definition: config.h:215
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
std::map< SUMOVehicle *, std::pair< SUMOReal, SUMOReal > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.