MSBusStop.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <cassert>
00031 #include "MSTrigger.h"
00032 #include "MSBusStop.h"
00033
00034 #ifdef CHECK_MEMORY_LEAKS
00035 #include <foreign/nvwa/debug_new.h>
00036 #endif // CHECK_MEMORY_LEAKS
00037
00038
00039
00040
00041
00042 MSBusStop::MSBusStop(const std::string &id,
00043 const std::vector<std::string> &lines,
00044 MSLane &lane,
00045 SUMOReal begPos, SUMOReal endPos) throw()
00046 : MSTrigger(id), myLines(lines), myLane(lane),
00047 myBegPos(begPos), myEndPos(endPos), myLastFreePos(endPos) {
00048 computeLastFreePos();
00049 }
00050
00051
00052 MSBusStop::~MSBusStop() throw() {}
00053
00054
00055 const MSLane &
00056 MSBusStop::getLane() const throw() {
00057 return myLane;
00058 }
00059
00060
00061 SUMOReal
00062 MSBusStop::getBeginLanePosition() const throw() {
00063 return myBegPos;
00064 }
00065
00066
00067 SUMOReal
00068 MSBusStop::getEndLanePosition() const throw() {
00069 return myEndPos;
00070 }
00071
00072
00073 void
00074 MSBusStop::enter(void *what, SUMOReal beg, SUMOReal end) throw() {
00075 myEndPositions[what] = std::pair<SUMOReal, SUMOReal>(beg, end);
00076 computeLastFreePos();
00077 }
00078
00079
00080 SUMOReal
00081 MSBusStop::getLastFreePos() const throw() {
00082 return myLastFreePos;
00083 }
00084
00085
00086 void
00087 MSBusStop::leaveFrom(void *what) throw() {
00088 assert(myEndPositions.find(what)!=myEndPositions.end());
00089 myEndPositions.erase(myEndPositions.find(what));
00090 computeLastFreePos();
00091 }
00092
00093
00094 void
00095 MSBusStop::computeLastFreePos() throw() {
00096 myLastFreePos = myEndPos;
00097 std::map<void*, std::pair<SUMOReal, SUMOReal> >::iterator i;
00098 for (i=myEndPositions.begin(); i!=myEndPositions.end(); i++) {
00099 if (myLastFreePos>(*i).second.second) {
00100 myLastFreePos = (*i).second.second;
00101 }
00102 }
00103 }
00104
00105
00106
00107
00108