SUMO - Simulation of Urban MObility

GUIInternalLane.cpp

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