GUIInternalLane.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Lane within junctions, derived from the normal lane
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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/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 // method definitions
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     // just to quit cleanly on a failure
00062     if (myLock.locked()) {
00063         myLock.unlock();
00064     }
00065 }
00066 
00067 
00068 // ------ Vehicle emission ------
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 // ------ Access to vehicles ------
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     // Insert vehicle only if it's destination isn't reached.
00124     //  and it does not collide with previous
00125     // check whether the vehicle has ended his route
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 

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6