GUIInternalLane.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 <string>
00031 #include <utility>
00032 #include <utils/common/MsgHandler.h>
00033 #include <utils/geom/Position2D.h>
00034 #include <microsim/MSLane.h>
00035 #include <microsim/MSVehicleControl.h>
00036 #include <microsim/MSVehicleTransfer.h>
00037 #include <microsim/MSNet.h>
00038 #include "GUINet.h"
00039 #include "GUIVehicle.h"
00040 #include "GUILaneWrapper.h"
00041 #include "GUIInternalLane.h"
00042
00043 #ifdef CHECK_MEMORY_LEAKS
00044 #include <foreign/nvwa/debug_new.h>
00045 #endif // CHECK_MEMORY_LEAKS
00046
00047
00048
00049
00050
00051 GUIInternalLane::GUIInternalLane(const std::string &id,
00052 SUMOReal maxSpeed, SUMOReal length,
00053 MSEdge * const edge, unsigned int numericalID,
00054 const Position2DVector &shape,
00055 const std::vector<SUMOVehicleClass> &allowed,
00056 const std::vector<SUMOVehicleClass> &disallowed) throw()
00057 : MSInternalLane(id, maxSpeed, length, edge, numericalID, shape, allowed, disallowed) {}
00058
00059
00060 GUIInternalLane::~GUIInternalLane() throw() {
00061
00062 if (myLock.locked()) {
00063 myLock.unlock();
00064 }
00065 }
00066
00067
00068
00069 bool
00070 GUIInternalLane::isEmissionSuccess(MSVehicle* aVehicle, SUMOReal speed, SUMOReal pos,
00071 bool recheckNextLanes) throw(ProcessError) {
00072 myLock.lock();
00073 bool ret = MSInternalLane::isEmissionSuccess(aVehicle, speed, pos, recheckNextLanes);
00074 myLock.unlock();
00075 return ret;
00076 }
00077
00078
00079
00080 const MSLane::VehCont &
00081 GUIInternalLane::getVehiclesSecure() const throw() {
00082 myLock.lock();
00083 return myVehicles;
00084 }
00085
00086
00087 void
00088 GUIInternalLane::releaseVehicles() const throw() {
00089 myLock.unlock();
00090 }
00091
00092
00093 bool
00094 GUIInternalLane::moveCritical(SUMOTime t) {
00095 myLock.lock();
00096 try {
00097 bool ret = MSInternalLane::moveCritical(t);
00098 myLock.unlock();
00099 return ret;
00100 } catch (ProcessError &) {
00101 myLock.unlock();
00102 throw;
00103 }
00104 }
00105
00106
00107 bool
00108 GUIInternalLane::setCritical(SUMOTime t, std::vector<MSLane*> &into) {
00109 myLock.lock();
00110 try {
00111 bool ret = MSInternalLane::setCritical(t, into);
00112 myLock.unlock();
00113 return ret;
00114 } catch (ProcessError &) {
00115 myLock.unlock();
00116 throw;
00117 }
00118 }
00119
00120
00121 bool
00122 GUIInternalLane::push(MSVehicle* veh) {
00123
00124
00125
00126 myLock.lock();
00127 try {
00128 MSLane::push(veh);
00129 myLock.unlock();
00130 return false;
00131 } catch (ProcessError &) {
00132 myLock.unlock();
00133 throw;
00134 }
00135 }
00136
00137
00138 MSVehicle *
00139 GUIInternalLane::removeFirstVehicle() {
00140 myLock.lock();
00141 try {
00142 MSVehicle *ret = MSLane::removeFirstVehicle();
00143 myLock.unlock();
00144 return ret;
00145 } catch (ProcessError &) {
00146 myLock.unlock();
00147 throw;
00148 }
00149 }
00150
00151
00152 MSVehicle *
00153 GUIInternalLane::removeVehicle(MSVehicle * remVehicle) {
00154 myLock.lock();
00155 try {
00156 MSVehicle *ret = MSLane::removeVehicle(remVehicle);
00157 myLock.unlock();
00158 return ret;
00159 } catch (ProcessError &) {
00160 myLock.unlock();
00161 throw;
00162 }
00163 }
00164
00165
00166 void
00167 GUIInternalLane::swapAfterLaneChange(SUMOTime t) {
00168 myLock.lock();
00169 try {
00170 MSLane::swapAfterLaneChange(t);
00171 myLock.unlock();
00172 } catch (ProcessError &) {
00173 myLock.unlock();
00174 throw;
00175 }
00176 }
00177
00178
00179 bool
00180 GUIInternalLane::integrateNewVehicle(SUMOTime t) {
00181 myLock.lock();
00182 try {
00183 bool ret = MSLane::integrateNewVehicle(t);
00184 myLock.unlock();
00185 return ret;
00186 } catch (ProcessError &) {
00187 myLock.unlock();
00188 throw;
00189 }
00190 }
00191
00192
00193 GUILaneWrapper *
00194 GUIInternalLane::buildLaneWrapper(GUIGlObjectStorage &idStorage) {
00195 return new GUILaneWrapper(idStorage, *this, myShape);
00196 }
00197
00198
00199 void
00200 GUIInternalLane::detectCollisions(SUMOTime timestep) {
00201 myLock.lock();
00202 try {
00203 MSLane::detectCollisions(timestep);
00204 myLock.unlock();
00205 } catch (ProcessError &) {
00206 myLock.unlock();
00207 throw;
00208 }
00209 }
00210
00211
00212 MSVehicle*
00213 GUIInternalLane::pop(SUMOTime t) {
00214 myLock.lock();
00215 try {
00216 MSVehicle *ret = MSLane::pop(t);
00217 myLock.unlock();
00218 return ret;
00219 } catch (ProcessError &) {
00220 myLock.unlock();
00221 throw;
00222 }
00223 }
00224
00225
00226
00227
00228