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