SUMO - Simulation of Urban MObility

GUILane.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Representation of a lane in the micro simulation (gui-version)
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <string>
00031 #include <utility>
00032 #include <utils/foxtools/MFXMutex.h>
00033 #include <utils/geom/Position.h>
00034 #include <utils/common/MsgHandler.h>
00035 #include <microsim/MSLane.h>
00036 #include <microsim/MSVehicleControl.h>
00037 #include <microsim/MSVehicleTransfer.h>
00038 #include <microsim/MSNet.h>
00039 #include "GUILane.h"
00040 #include "GUIVehicle.h"
00041 #include "GUINet.h"
00042 
00043 #ifdef CHECK_MEMORY_LEAKS
00044 #include <foreign/nvwa/debug_new.h>
00045 #endif // CHECK_MEMORY_LEAKS
00046 
00047 
00048 // ===========================================================================
00049 // method definitions
00050 // ===========================================================================
00051 GUILane::GUILane(const std::string& id, SUMOReal maxSpeed, SUMOReal length,
00052                  MSEdge* const edge, unsigned int numericalID,
00053                  const PositionVector& shape, SUMOReal width,
00054                  const SUMOVehicleClasses& allowed,
00055                  const SUMOVehicleClasses& disallowed) throw()
00056     : MSLane(id, maxSpeed, length, edge, numericalID, shape, width, allowed, disallowed) {}
00057 
00058 
00059 GUILane::~GUILane() throw() {
00060     // just to quit cleanly on a failure
00061     if (myLock.locked()) {
00062         myLock.unlock();
00063     }
00064 }
00065 
00066 
00067 // ------ Vehicle insertion ------
00068 void
00069 GUILane::incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed,
00070                             const MSLane::VehCont::iterator& at,
00071                             MSMoveReminder::Notification notification) throw(ProcessError) {
00072     myLock.lock();
00073     try {
00074         MSLane::incorporateVehicle(veh, pos, speed, at, notification);
00075         myLock.unlock();
00076     } catch (ProcessError&) {
00077         myLock.unlock();
00078         throw;
00079     }
00080 }
00081 
00082 
00083 // ------ Access to vehicles ------
00084 const MSLane::VehCont&
00085 GUILane::getVehiclesSecure() const throw() {
00086     myLock.lock();
00087     return myVehicles;
00088 }
00089 
00090 
00091 void
00092 GUILane::releaseVehicles() const throw() {
00093     myLock.unlock();
00094 }
00095 
00096 
00097 bool
00098 GUILane::moveCritical(SUMOTime t) {
00099     myLock.lock();
00100     try {
00101         bool ret = MSLane::moveCritical(t);
00102         myLock.unlock();
00103         return ret;
00104     } catch (ProcessError&) {
00105         myLock.unlock();
00106         throw;
00107     }
00108 }
00109 
00110 
00111 bool
00112 GUILane::setCritical(SUMOTime t, std::vector<MSLane*> &into) {
00113     myLock.lock();
00114     try {
00115         bool ret = MSLane::setCritical(t, into);
00116         myLock.unlock();
00117         return ret;
00118     } catch (ProcessError&) {
00119         myLock.unlock();
00120         throw;
00121     }
00122 }
00123 
00124 
00125 MSVehicle*
00126 GUILane::removeVehicle(MSVehicle* remVehicle) {
00127     myLock.lock();
00128     try {
00129         MSVehicle* ret = MSLane::removeVehicle(remVehicle);
00130         myLock.unlock();
00131         return ret;
00132     } catch (ProcessError&) {
00133         myLock.unlock();
00134         throw;
00135     }
00136 }
00137 
00138 
00139 void
00140 GUILane::swapAfterLaneChange(SUMOTime t) {
00141     myLock.lock();
00142     try {
00143         MSLane::swapAfterLaneChange(t);
00144         myLock.unlock();
00145     } catch (ProcessError&) {
00146         myLock.unlock();
00147         throw;
00148     }
00149 }
00150 
00151 
00152 bool
00153 GUILane::integrateNewVehicle(SUMOTime t) {
00154     myLock.lock();
00155     try {
00156         bool ret = MSLane::integrateNewVehicle(t);
00157         myLock.unlock();
00158         return ret;
00159     } catch (ProcessError&) {
00160         myLock.unlock();
00161         throw;
00162     }
00163 }
00164 
00165 
00166 GUILaneWrapper*
00167 GUILane::buildLaneWrapper(unsigned int index) {
00168     return new GUILaneWrapper(*this, myShape, index);
00169 }
00170 
00171 
00172 void
00173 GUILane::detectCollisions(SUMOTime timestep) {
00174     myLock.lock();
00175     try {
00176         MSLane::detectCollisions(timestep);
00177         myLock.unlock();
00178     } catch (ProcessError&) {
00179         myLock.unlock();
00180         throw;
00181     }
00182 }
00183 
00184 
00185 
00186 /****************************************************************************/
00187 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines