LCOV - code coverage report
Current view: top level - src/netimport/vissim/tempstructs - NIVissimSource.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 75.0 % 20 15
Test Date: 2024-11-22 15:46:21 Functions: 83.3 % 6 5

            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    NIVissimSource.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @date    Sept 2002
      17              : ///
      18              : // -------------------
      19              : /****************************************************************************/
      20              : #include <config.h>
      21              : 
      22              : 
      23              : #include <string>
      24              : #include <map>
      25              : #include "NIVissimSource.h"
      26              : 
      27              : NIVissimSource::DictType NIVissimSource::myDict;
      28              : 
      29          100 : NIVissimSource::NIVissimSource(const std::string& id, const std::string& name,
      30          100 :                                const std::string& edgeid)
      31          300 :     : myID(id), myName(name), myEdgeID(edgeid) {}
      32              : 
      33              : 
      34          100 : NIVissimSource::~NIVissimSource() {}
      35              : 
      36              : 
      37              : bool
      38          100 : NIVissimSource::dictionary(const std::string& id, const std::string& name,
      39              :                            const std::string& edgeid) {
      40          100 :     NIVissimSource* o = new NIVissimSource(id, name, edgeid);
      41          100 :     if (!dictionary(id, o)) {
      42            0 :         delete o;
      43            0 :         return false;
      44              :     }
      45              :     return true;
      46              : }
      47              : 
      48              : 
      49              : bool
      50          100 : NIVissimSource::dictionary(const std::string& id, NIVissimSource* o) {
      51              :     DictType::iterator i = myDict.find(id);
      52          100 :     if (i == myDict.end()) {
      53          100 :         myDict[id] = o;
      54          100 :         return true;
      55              :     }
      56              :     return false;
      57              : }
      58              : 
      59              : 
      60              : NIVissimSource*
      61            0 : NIVissimSource::dictionary(const std::string& id) {
      62              :     DictType::iterator i = myDict.find(id);
      63            0 :     if (i == myDict.end()) {
      64              :         return nullptr;
      65              :     }
      66            0 :     return (*i).second;
      67              : }
      68              : 
      69              : 
      70              : void
      71            9 : NIVissimSource::clearDict() {
      72          109 :     for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
      73          100 :         delete (*i).second;
      74              :     }
      75              :     myDict.clear();
      76            9 : }
      77              : 
      78              : 
      79              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1