SUMO - Simulation of Urban MObility

MSBusStop.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A lane area vehicles can halt at
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This file is part of SUMO.
00014 //   SUMO is free software: you can redistribute it and/or modify
00015 //   it under the terms of the GNU General Public License as published by
00016 //   the Free Software Foundation, either version 3 of the License, or
00017 //   (at your option) any later version.
00018 //
00019 /****************************************************************************/
00020 
00021 
00022 // ===========================================================================
00023 // included modules
00024 // ===========================================================================
00025 #ifdef _MSC_VER
00026 #include <windows_config.h>
00027 #else
00028 #include <config.h>
00029 #endif
00030 
00031 #include <cassert>
00032 #include "MSTrigger.h"
00033 #include "MSBusStop.h"
00034 
00035 #ifdef CHECK_MEMORY_LEAKS
00036 #include <foreign/nvwa/debug_new.h>
00037 #endif // CHECK_MEMORY_LEAKS
00038 
00039 
00040 // ===========================================================================
00041 // method definitions
00042 // ===========================================================================
00043 MSBusStop::MSBusStop(const std::string& id,
00044                      const std::vector<std::string> &lines,
00045                      MSLane& lane,
00046                      SUMOReal begPos, SUMOReal endPos)
00047     : MSTrigger(id), myLines(lines), myLane(lane),
00048       myBegPos(begPos), myEndPos(endPos), myLastFreePos(endPos) {
00049     computeLastFreePos();
00050 }
00051 
00052 
00053 MSBusStop::~MSBusStop() {}
00054 
00055 
00056 const MSLane&
00057 MSBusStop::getLane() const {
00058     return myLane;
00059 }
00060 
00061 
00062 SUMOReal
00063 MSBusStop::getBeginLanePosition() const {
00064     return myBegPos;
00065 }
00066 
00067 
00068 SUMOReal
00069 MSBusStop::getEndLanePosition() const {
00070     return myEndPos;
00071 }
00072 
00073 
00074 void
00075 MSBusStop::enter(void* what, SUMOReal beg, SUMOReal end) {
00076     myEndPositions[what] = std::pair<SUMOReal, SUMOReal>(beg, end);
00077     computeLastFreePos();
00078 }
00079 
00080 
00081 SUMOReal
00082 MSBusStop::getLastFreePos() const {
00083     return myLastFreePos;
00084 }
00085 
00086 
00087 void
00088 MSBusStop::leaveFrom(void* what) {
00089     assert(myEndPositions.find(what) != myEndPositions.end());
00090     myEndPositions.erase(myEndPositions.find(what));
00091     computeLastFreePos();
00092 }
00093 
00094 
00095 void
00096 MSBusStop::computeLastFreePos() {
00097     myLastFreePos = myEndPos;
00098     std::map<void*, std::pair<SUMOReal, SUMOReal> >::iterator i;
00099     for (i = myEndPositions.begin(); i != myEndPositions.end(); i++) {
00100         if (myLastFreePos > (*i).second.second) {
00101             myLastFreePos = (*i).second.second;
00102         }
00103     }
00104 }
00105 
00106 
00107 
00108 /****************************************************************************/
00109 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines