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