LCOV - code coverage report
Current view: top level - src/mesogui - GUIMEVehicleControl.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 76.3 % 38 29
Test Date: 2026-05-24 16:29:35 Functions: 90.9 % 11 10

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    GUIMEVehicleControl.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @date    Okt 2012
      17              : ///
      18              : // The class responsible for building and deletion of meso vehicles (gui-version)
      19              : /****************************************************************************/
      20              : #include <config.h>
      21              : 
      22              : #include <utils/foxtools/fxheader.h>
      23              : #include <utils/vehicle/SUMOVehicle.h>
      24              : #include <gui/GUIGlobals.h>
      25              : #include <microsim/MSRouteHandler.h>
      26              : #include "GUIMEVehicleControl.h"
      27              : #include "GUIMEVehicle.h"
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // member method definitions
      32              : // ===========================================================================
      33         2927 : GUIMEVehicleControl::GUIMEVehicleControl()
      34         2927 :     : MEVehicleControl() {}
      35              : 
      36              : 
      37         5854 : GUIMEVehicleControl::~GUIMEVehicleControl() {
      38              :     // just to quit cleanly on a failure
      39         2927 :     if (myLock.locked()) {
      40            0 :         myLock.unlock();
      41              :     }
      42         5854 : }
      43              : 
      44              : 
      45              : SUMOVehicle*
      46       292886 : GUIMEVehicleControl::buildVehicle(SUMOVehicleParameter* defs,
      47              :                                   ConstMSRoutePtr route, MSVehicleType* type,
      48              :                                   const bool ignoreStopErrors, const VehicleDefinitionSource source,
      49              :                                   bool addRouteStops) {
      50       299623 :     const double speedFactor = type->computeChosenSpeedDeviation(defs->speedFactor, source == VehicleDefinitionSource::ROUTEFILE ? MSRouteHandler::getParsingRNG() : nullptr);
      51       585772 :     MSBaseVehicle* built = new GUIMEVehicle(defs, route, type, speedFactor);
      52       292886 :     initVehicle(built, ignoreStopErrors, addRouteStops, source);
      53       292860 :     return built;
      54              : }
      55              : 
      56              : 
      57              : 
      58              : bool
      59       292596 : GUIMEVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
      60       292596 :     FXMutexLock locker(myLock);
      61       585192 :     return MEVehicleControl::addVehicle(id, v);
      62              : }
      63              : 
      64              : 
      65              : void
      66       267674 : GUIMEVehicleControl::deleteVehicle(SUMOVehicle* veh, bool discard, bool wasKept) {
      67       267674 :     FXMutexLock locker(myLock);
      68       267674 :     MEVehicleControl::deleteVehicle(veh, discard, wasKept);
      69       267674 : }
      70              : 
      71              : 
      72              : void
      73            0 : GUIMEVehicleControl::insertVehicleIDs(std::vector<GUIGlID>& into) {
      74            0 :     FXMutexLock locker(myLock);
      75            0 :     into.reserve(myVehicleDict.size());
      76            0 :     for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
      77            0 :         SUMOVehicle* veh = (*i).second;
      78            0 :         if (veh->isOnRoad()) {
      79            0 :             into.push_back(static_cast<GUIMEVehicle*>((*i).second)->getGlID());
      80              :         }
      81              :     }
      82            0 : }
      83              : 
      84              : std::pair<double, double>
      85        19632 : GUIMEVehicleControl::getVehicleMeanSpeeds() const {
      86        19632 :     FXMutexLock locker(myLock);
      87        39264 :     return MSVehicleControl::getVehicleMeanSpeeds();
      88              : }
      89              : 
      90              : 
      91              : int
      92        19632 : GUIMEVehicleControl::getHaltingVehicleNo() const {
      93        19632 :     FXMutexLock locker(myLock);
      94        39264 :     return MSVehicleControl::getHaltingVehicleNo();
      95              : }
      96              : 
      97              : 
      98              : void
      99       513195 : GUIMEVehicleControl::secureVehicles() {
     100       513195 :     myLock.lock();
     101       513195 : }
     102              : 
     103              : 
     104              : void
     105       513195 : GUIMEVehicleControl::releaseVehicles() {
     106       513195 :     myLock.unlock();
     107       513195 : }
     108              : 
     109              : 
     110              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1