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

            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         5034 : GUIVehicleControl::GUIVehicleControl()
      36         5034 :     : MSVehicleControl() {}
      37              : 
      38              : 
      39        10042 : GUIVehicleControl::~GUIVehicleControl() {
      40              :     // just to quit cleanly on a failure
      41         5021 :     if (myLock.locked()) {
      42            0 :         myLock.unlock();
      43              :     }
      44        10042 : }
      45              : 
      46              : 
      47              : SUMOVehicle*
      48       477631 : GUIVehicleControl::buildVehicle(SUMOVehicleParameter* defs,
      49              :                                 ConstMSRoutePtr route, MSVehicleType* type,
      50              :                                 const bool ignoreStopErrors, const VehicleDefinitionSource source,
      51              :                                 bool addRouteStops) {
      52       980334 :     MSVehicle* built = new GUIVehicle(defs, route, type, type->computeChosenSpeedDeviation(source == VehicleDefinitionSource::ROUTEFILE ? MSRouteHandler::getParsingRNG() : nullptr));
      53       477631 :     initVehicle(built, ignoreStopErrors, addRouteStops, source);
      54       477624 :     return built;
      55              : }
      56              : 
      57              : 
      58              : bool
      59       457976 : GUIVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
      60       457976 :     FXMutexLock locker(myLock);
      61       915952 :     return MSVehicleControl::addVehicle(id, v);
      62              : }
      63              : 
      64              : 
      65              : void
      66       427578 : GUIVehicleControl::deleteVehicle(SUMOVehicle* veh, bool discard, bool wasKept) {
      67       427578 :     FXMutexLock locker(myLock);
      68       427578 :     MSVehicleControl::deleteVehicle(veh, discard, wasKept);
      69       427578 : }
      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 2.0-1