LCOV - code coverage report
Current view: top level - src/microsim - MSEdgeWeightsStorage.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 36 36
Test Date: 2024-10-24 15:46:30 Functions: 100.0 % 10 10

            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    MSEdgeWeightsStorage.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Laura Bieker
      17              : /// @author  Michael Behrisch
      18              : /// @date    02.11.2009
      19              : ///
      20              : // A storage for edge travel times and efforts
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include "MSEdgeWeightsStorage.h"
      25              : 
      26              : 
      27              : // ===========================================================================
      28              : // method definitions
      29              : // ===========================================================================
      30        14810 : MSEdgeWeightsStorage::MSEdgeWeightsStorage() {
      31        14810 : }
      32              : 
      33              : 
      34        14808 : MSEdgeWeightsStorage::~MSEdgeWeightsStorage() {
      35        14808 : }
      36              : 
      37              : 
      38              : bool
      39     10287703 : MSEdgeWeightsStorage::retrieveExistingTravelTime(const MSEdge* const e, const double t, double& value) const {
      40              :     std::map<const MSEdge*, ValueTimeLine<double> >::const_iterator i = myTravelTimes.find(e);
      41     10287703 :     if (i == myTravelTimes.end()) {
      42              :         return false;
      43              :     }
      44          551 :     const ValueTimeLine<double>& tl = (*i).second;
      45          551 :     if (!tl.describesTime(t)) {
      46              :         return false;
      47              :     }
      48          533 :     value = tl.getValue(t);
      49          533 :     return true;
      50              : }
      51              : 
      52              : 
      53              : bool
      54          491 : MSEdgeWeightsStorage::retrieveExistingEffort(const MSEdge* const e, const double t, double& value) const {
      55              :     std::map<const MSEdge*, ValueTimeLine<double> >::const_iterator i = myEfforts.find(e);
      56          491 :     if (i == myEfforts.end()) {
      57              :         return false;
      58              :     }
      59           59 :     const ValueTimeLine<double>& tl = (*i).second;
      60           59 :     if (!tl.describesTime(t)) {
      61              :         return false;
      62              :     }
      63           51 :     value = tl.getValue(t);
      64           51 :     return true;
      65              : }
      66              : 
      67              : 
      68              : void
      69          289 : MSEdgeWeightsStorage::addTravelTime(const MSEdge* const e,
      70              :                                     double begin, double end,
      71              :                                     double value) {
      72              :     std::map<const MSEdge*, ValueTimeLine<double> >::iterator i = myTravelTimes.find(e);
      73          289 :     if (i == myTravelTimes.end()) {
      74          546 :         myTravelTimes[e] = ValueTimeLine<double>();
      75              :         i = myTravelTimes.find(e);
      76              :     }
      77          289 :     (*i).second.add(begin, end, value);
      78          289 : }
      79              : 
      80              : 
      81              : void
      82           40 : MSEdgeWeightsStorage::addEffort(const MSEdge* const e,
      83              :                                 double begin, double end,
      84              :                                 double value) {
      85              :     std::map<const MSEdge*, ValueTimeLine<double> >::iterator i = myEfforts.find(e);
      86           40 :     if (i == myEfforts.end()) {
      87           64 :         myEfforts[e] = ValueTimeLine<double>();
      88              :         i = myEfforts.find(e);
      89              :     }
      90           40 :     (*i).second.add(begin, end, value);
      91           40 : }
      92              : 
      93              : 
      94              : void
      95            9 : MSEdgeWeightsStorage::removeTravelTime(const MSEdge* const e) {
      96              :     std::map<const MSEdge*, ValueTimeLine<double> >::iterator i = myTravelTimes.find(e);
      97            9 :     if (i != myTravelTimes.end()) {
      98              :         myTravelTimes.erase(i);
      99              :     }
     100            9 : }
     101              : 
     102              : 
     103              : void
     104            9 : MSEdgeWeightsStorage::removeEffort(const MSEdge* const e) {
     105              :     std::map<const MSEdge*, ValueTimeLine<double> >::iterator i = myEfforts.find(e);
     106            9 :     if (i != myEfforts.end()) {
     107              :         myEfforts.erase(i);
     108              :     }
     109            9 : }
     110              : 
     111              : 
     112              : bool
     113          177 : MSEdgeWeightsStorage::knowsTravelTime(const MSEdge* const e) const {
     114          177 :     return myTravelTimes.find(e) != myTravelTimes.end();
     115              : }
     116              : 
     117              : 
     118              : bool
     119           27 : MSEdgeWeightsStorage::knowsEffort(const MSEdge* const e) const {
     120           27 :     return myEfforts.find(e) != myEfforts.end();
     121              : }
     122              : 
     123              : 
     124              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1