LCOV - code coverage report
Current view: top level - src/guisim - GUIVehicleControl.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 22 37 59.5 %
Date: 2024-04-27 15:34:54 Functions: 8 11 72.7 %

          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    GUIVehicleControl.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Jakob Erdmann
      17             : /// @author  Michael Behrisch
      18             : /// @date    Wed, 10. Dec 2003
      19             : ///
      20             : // The class responsible for building and deletion of vehicles (gui-version)
      21             : /****************************************************************************/
      22             : #include <config.h>
      23             : 
      24             : #include <utils/foxtools/fxheader.h>
      25             : #include <microsim/MSRouteHandler.h>
      26             : #include "GUIVehicleControl.h"
      27             : #include "GUIVehicle.h"
      28             : #include "GUINet.h"
      29             : #include <gui/GUIGlobals.h>
      30             : 
      31             : 
      32             : // ===========================================================================
      33             : // member method definitions
      34             : // ===========================================================================
      35        4872 : GUIVehicleControl::GUIVehicleControl()
      36        4872 :     : MSVehicleControl() {}
      37             : 
      38             : 
      39        9710 : GUIVehicleControl::~GUIVehicleControl() {
      40             :     // just to quit cleanly on a failure
      41        4855 :     if (myLock.locked()) {
      42           0 :         myLock.unlock();
      43             :     }
      44        9710 : }
      45             : 
      46             : 
      47             : SUMOVehicle*
      48      408049 : GUIVehicleControl::buildVehicle(SUMOVehicleParameter* defs,
      49             :                                 ConstMSRoutePtr route, MSVehicleType* type,
      50             :                                 const bool ignoreStopErrors, const bool fromRouteFile,
      51             :                                 bool addRouteStops) {
      52      432613 :     MSVehicle* built = new GUIVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
      53      408049 :     initVehicle(built, ignoreStopErrors, addRouteStops);
      54      408042 :     return built;
      55             : }
      56             : 
      57             : 
      58             : bool
      59      388400 : GUIVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
      60      388400 :     FXMutexLock locker(myLock);
      61      776800 :     return MSVehicleControl::addVehicle(id, v);
      62             : }
      63             : 
      64             : 
      65             : void
      66      359807 : GUIVehicleControl::deleteVehicle(SUMOVehicle* veh, bool discard) {
      67      359807 :     FXMutexLock locker(myLock);
      68      359807 :     MSVehicleControl::deleteVehicle(veh, discard);
      69      359807 : }
      70             : 
      71             : 
      72             : int
      73       22186 : GUIVehicleControl::getHaltingVehicleNo() const {
      74       22186 :     FXMutexLock locker(myLock);
      75       44372 :     return MSVehicleControl::getHaltingVehicleNo();
      76             : }
      77             : 
      78             : 
      79             : std::pair<double, double>
      80       22186 : GUIVehicleControl::getVehicleMeanSpeeds() const {
      81       22186 :     FXMutexLock locker(myLock);
      82       44372 :     return MSVehicleControl::getVehicleMeanSpeeds();
      83             : }
      84             : 
      85             : 
      86             : void
      87           0 : GUIVehicleControl::insertVehicleIDs(std::vector<GUIGlID>& into, bool listParking, bool listTeleporting) {
      88           0 :     FXMutexLock locker(myLock);
      89           0 :     into.reserve(myVehicleDict.size());
      90           0 :     for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
      91           0 :         SUMOVehicle* veh = (*i).second;
      92           0 :         if (veh->isOnRoad() || (listParking && veh->isParking()) || listTeleporting) {
      93           0 :             into.push_back(static_cast<GUIVehicle*>((*i).second)->getGlID());
      94             :         }
      95             :     }
      96           0 : }
      97             : 
      98             : 
      99             : void
     100           0 : GUIVehicleControl::secureVehicles() {
     101           0 :     myLock.lock();
     102           0 : }
     103             : 
     104             : 
     105             : void
     106           0 : GUIVehicleControl::releaseVehicles() {
     107           0 :     myLock.unlock();
     108           0 : }
     109             : 
     110             : 
     111             : /****************************************************************************/

Generated by: LCOV version 1.14