LCOV - code coverage report
Current view: top level - src/mesogui - GUIMEVehicleControl.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 28 37 75.7 %
Date: 2024-05-02 15:31:40 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 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        2361 : GUIMEVehicleControl::GUIMEVehicleControl()
      34        2361 :     : MEVehicleControl() {}
      35             : 
      36             : 
      37        4722 : GUIMEVehicleControl::~GUIMEVehicleControl() {
      38             :     // just to quit cleanly on a failure
      39        2361 :     if (myLock.locked()) {
      40           0 :         myLock.unlock();
      41             :     }
      42        4722 : }
      43             : 
      44             : 
      45             : SUMOVehicle*
      46      274966 : GUIMEVehicleControl::buildVehicle(SUMOVehicleParameter* defs,
      47             :                                   ConstMSRoutePtr route, MSVehicleType* type,
      48             :                                   const bool ignoreStopErrors, const bool fromRouteFile,
      49             :                                   bool addRouteStops) {
      50      281631 :     MSBaseVehicle* built = new GUIMEVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
      51      274966 :     initVehicle(built, ignoreStopErrors, addRouteStops);
      52      274962 :     return built;
      53             : }
      54             : 
      55             : 
      56             : 
      57             : bool
      58      274725 : GUIMEVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
      59      274725 :     FXMutexLock locker(myLock);
      60      549450 :     return MEVehicleControl::addVehicle(id, v);
      61             : }
      62             : 
      63             : 
      64             : void
      65      251766 : GUIMEVehicleControl::deleteVehicle(SUMOVehicle* veh, bool discard) {
      66      251766 :     FXMutexLock locker(myLock);
      67      251766 :     MEVehicleControl::deleteVehicle(veh, discard);
      68      251766 : }
      69             : 
      70             : 
      71             : void
      72           0 : GUIMEVehicleControl::insertVehicleIDs(std::vector<GUIGlID>& into) {
      73           0 :     FXMutexLock locker(myLock);
      74           0 :     into.reserve(myVehicleDict.size());
      75           0 :     for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
      76           0 :         SUMOVehicle* veh = (*i).second;
      77           0 :         if (veh->isOnRoad()) {
      78           0 :             into.push_back(static_cast<GUIMEVehicle*>((*i).second)->getGlID());
      79             :         }
      80             :     }
      81           0 : }
      82             : 
      83             : std::pair<double, double>
      84       19637 : GUIMEVehicleControl::getVehicleMeanSpeeds() const {
      85       19637 :     FXMutexLock locker(myLock);
      86       39274 :     return MSVehicleControl::getVehicleMeanSpeeds();
      87             : }
      88             : 
      89             : 
      90             : int
      91       19637 : GUIMEVehicleControl::getHaltingVehicleNo() const {
      92       19637 :     FXMutexLock locker(myLock);
      93       39274 :     return MSVehicleControl::getHaltingVehicleNo();
      94             : }
      95             : 
      96             : 
      97             : void
      98      290927 : GUIMEVehicleControl::secureVehicles() {
      99      290927 :     myLock.lock();
     100      290927 : }
     101             : 
     102             : 
     103             : void
     104      290927 : GUIMEVehicleControl::releaseVehicles() {
     105      290927 :     myLock.unlock();
     106      290927 : }
     107             : 
     108             : 
     109             : /****************************************************************************/

Generated by: LCOV version 1.14