SUMO - Simulation of Urban MObility

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 (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/common/MsgHandler.h>
00033 #include <utils/geom/Position.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 PositionVector& shape, SUMOReal width,
00055                                  const SUMOVehicleClasses& allowed,
00056                                  const SUMOVehicleClasses& disallowed) throw()
00057     : MSInternalLane(id, maxSpeed, length, edge, numericalID, shape, width, 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 insertion ------
00069 void
00070 GUIInternalLane::incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed,
00071                                     const MSLane::VehCont::iterator& at,
00072                                     MSMoveReminder::Notification notification) throw(ProcessError) {
00073     myLock.lock();
00074     try {
00075         MSInternalLane::incorporateVehicle(veh, pos, speed, at, notification);
00076         myLock.unlock();
00077     } catch (ProcessError&) {
00078         myLock.unlock();
00079         throw;
00080     }
00081 }
00082 
00083 
00084 // ------ Access to vehicles ------
00085 const MSLane::VehCont&
00086 GUIInternalLane::getVehiclesSecure() const throw() {
00087     myLock.lock();
00088     return myVehicles;
00089 }
00090 
00091 
00092 void
00093 GUIInternalLane::releaseVehicles() const throw() {
00094     myLock.unlock();
00095 }
00096 
00097 
00098 bool
00099 GUIInternalLane::moveCritical(SUMOTime t) {
00100     myLock.lock();
00101     try {
00102         bool ret = MSInternalLane::moveCritical(t);
00103         myLock.unlock();
00104         return ret;
00105     } catch (ProcessError&) {
00106         myLock.unlock();
00107         throw;
00108     }
00109 }
00110 
00111 
00112 bool
00113 GUIInternalLane::setCritical(SUMOTime t, std::vector<MSLane*> &into) {
00114     myLock.lock();
00115     try {
00116         bool ret = MSInternalLane::setCritical(t, into);
00117         myLock.unlock();
00118         return ret;
00119     } catch (ProcessError&) {
00120         myLock.unlock();
00121         throw;
00122     }
00123 }
00124 
00125 
00126 MSVehicle*
00127 GUIInternalLane::removeVehicle(MSVehicle* remVehicle) {
00128     myLock.lock();
00129     try {
00130         MSVehicle* ret = MSLane::removeVehicle(remVehicle);
00131         myLock.unlock();
00132         return ret;
00133     } catch (ProcessError&) {
00134         myLock.unlock();
00135         throw;
00136     }
00137 }
00138 
00139 
00140 void
00141 GUIInternalLane::swapAfterLaneChange(SUMOTime t) {
00142     myLock.lock();
00143     try {
00144         MSLane::swapAfterLaneChange(t);
00145         myLock.unlock();
00146     } catch (ProcessError&) {
00147         myLock.unlock();
00148         throw;
00149     }
00150 }
00151 
00152 
00153 bool
00154 GUIInternalLane::integrateNewVehicle(SUMOTime t) {
00155     myLock.lock();
00156     try {
00157         bool ret = MSLane::integrateNewVehicle(t);
00158         myLock.unlock();
00159         return ret;
00160     } catch (ProcessError&) {
00161         myLock.unlock();
00162         throw;
00163     }
00164 }
00165 
00166 
00167 GUILaneWrapper*
00168 GUIInternalLane::buildLaneWrapper(unsigned int index) {
00169     return new GUILaneWrapper(*this, myShape, index);
00170 }
00171 
00172 
00173 void
00174 GUIInternalLane::detectCollisions(SUMOTime timestep) {
00175     myLock.lock();
00176     try {
00177         MSLane::detectCollisions(timestep);
00178         myLock.unlock();
00179     } catch (ProcessError&) {
00180         myLock.unlock();
00181         throw;
00182     }
00183 }
00184 
00185 
00186 
00187 /****************************************************************************/
00188 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines