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

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