SUMO - Simulation of Urban MObility
MSContainerStop.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A lane area vehicles can halt at and load and unload containers
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 MSContainerStop_h
22 #define MSContainerStop_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 <set>
39 #include <utils/common/Named.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSLane;
46 class SUMOVehicle;
47 class MSContainer;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
65 class MSContainerStop : public Named {
66 public:
76  MSContainerStop(const std::string& id,
77  const std::vector<std::string>& lines, MSLane& lane,
78  SUMOReal begPos, SUMOReal endPos);
79 
80 
82  virtual ~MSContainerStop();
83 
84 
89  const MSLane& getLane() const;
90 
91 
97 
98 
104 
105 
117  void enter(SUMOVehicle* what, SUMOReal beg, SUMOReal end);
118 
119 
129  void leaveFrom(SUMOVehicle* what);
130 
131 
136  SUMOReal getLastFreePos(const SUMOVehicle& forVehicle) const;
137 
138 
141  unsigned int getContainerNumber() const {
142  return static_cast<unsigned int>(myWaitingContainers.size());
143  }
144 
146  void addContainer(MSContainer* container) {
147  myWaitingContainers.push_back(container);
148  }
149 
151  void removeContainer(MSContainer* container) {
152  std::vector<MSContainer*>::iterator i = std::find(myWaitingContainers.begin(), myWaitingContainers.end(), container);
153  if (i != myWaitingContainers.end()) {
154  myWaitingContainers.erase(i);
155  }
156  }
157 
158 protected:
165  void computeLastFreePos();
166 
167 
168 protected:
170  std::vector<std::string> myLines;
171 
173  std::map<SUMOVehicle*, std::pair<SUMOReal, SUMOReal> > myEndPositions;
174 
177 
180 
183 
186 
188  std::vector<MSContainer*> myWaitingContainers;
189 
190 
191 private:
194 
197 
198 
199 };
200 
201 
202 #endif
203 
204 /****************************************************************************/
205 
const MSLane & getLane() const
Returns the lane this container stop is located at.
A lane area vehicles can halt at and load and unload containers.
MSContainerStop(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, SUMOReal begPos, SUMOReal endPos)
Constructor.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
SUMOReal getEndLanePosition() const
Returns the end position of this container stop.
virtual ~MSContainerStop()
Destructor.
SUMOReal myBegPos
The begin position this stop is located at.
SUMOReal getBeginLanePosition() const
Returns the begin position of this container stop.
SUMOReal myEndPos
The end position this stop is located at.
SUMOReal getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
std::map< SUMOVehicle *, std::pair< SUMOReal, SUMOReal > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
void computeLastFreePos()
Computes the last free position on this stop.
void addContainer(MSContainer *container)
Adds a container to this stop.
std::vector< MSContainer * > myWaitingContainers
Containers waiting at this stop.
MSLane & myLane
The lane this stop is located at.
unsigned int getContainerNumber() const
Returns the number of containers waiting on this stop.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
MSContainerStop & operator=(const MSContainerStop &)
Invalidated assignment operator.
Base class for objects which have an id.
Definition: Named.h:45
void removeContainer(MSContainer *container)
Removes a container from this stop.
void enter(SUMOVehicle *what, SUMOReal beg, SUMOReal end)
Called if a vehicle enters this stop.
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
SUMOReal myLastFreePos
The last free position at this stop (variable)
#define SUMOReal
Definition: config.h:218
Representation of a lane in the micro simulation.
Definition: MSLane.h:77