LCOV - code coverage report
Current view: top level - src/netimport/vissim/typeloader - NIVissimSingleTypeParser_Signalgeberdefinition.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 29 35 82.9 %
Date: 2024-05-01 15:34:42 Functions: 4 4 100.0 %

          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    NIVissimSingleTypeParser_Signalgeberdefinition.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Michael Behrisch
      17             : /// @date    Wed, 18 Dec 2002
      18             : ///
      19             : //
      20             : /****************************************************************************/
      21             : #include <config.h>
      22             : 
      23             : #include <cassert>
      24             : #include <iostream>
      25             : #include <utils/common/StringUtils.h>
      26             : #include <utils/common/ToString.h>
      27             : #include <utils/common/MsgHandler.h>
      28             : #include <utils/common/VectorHelper.h>
      29             : #include <netimport/vissim/NIImporter_Vissim.h>
      30             : #include <netimport/vissim/tempstructs/NIVissimTL.h>
      31             : #include "NIVissimSingleTypeParser_Signalgeberdefinition.h"
      32             : 
      33             : 
      34             : // ===========================================================================
      35             : // method definitions
      36             : // ===========================================================================
      37           9 : NIVissimSingleTypeParser_Signalgeberdefinition::NIVissimSingleTypeParser_Signalgeberdefinition(NIImporter_Vissim& parent)
      38           9 :     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
      39             : 
      40             : 
      41          18 : NIVissimSingleTypeParser_Signalgeberdefinition::~NIVissimSingleTypeParser_Signalgeberdefinition() {}
      42             : 
      43             : 
      44             : bool
      45         155 : NIVissimSingleTypeParser_Signalgeberdefinition::parse(std::istream& from) {
      46             :     //
      47             :     int id;
      48         155 :     from >> id;
      49             :     //
      50             :     std::string tag, name;
      51         310 :     tag = myRead(from);
      52         155 :     if (tag == "name") {
      53         155 :         name = readName(from);
      54         310 :         tag = myRead(from);
      55             :     }
      56             :     // skip optional "Beschriftung"
      57         310 :     tag = overrideOptionalLabel(from, tag);
      58             :     //
      59             :     int lsaid;
      60             :     std::vector<int> groupids;
      61         155 :     if (tag == "lsa") {
      62             :         int groupid;
      63         155 :         from >> lsaid; // type-checking is missing!
      64         155 :         from >> tag; // "Gruppe"
      65             :         do {
      66         158 :             from >> groupid;
      67         158 :             groupids.push_back(groupid);
      68         316 :             tag = myRead(from);
      69         158 :         } while (tag == "oder");
      70             :         //
      71             :     } else {
      72           0 :         from >> tag; // strecke
      73           0 :         WRITE_WARNING(TL("Omitting unknown traffic light."));
      74           0 :         return true;
      75             :     }
      76         155 :     if (tag == "typ") {
      77           0 :         from >> tag; // typ-value
      78           0 :         from >> tag; // "ort"
      79             :     }
      80             : 
      81             :     //
      82         155 :     from >> tag;
      83             :     int edgeid;
      84         155 :     from >> edgeid;
      85             : 
      86         155 :     from >> tag;
      87             :     int laneno;
      88         155 :     from >> laneno;
      89             : 
      90         155 :     from >> tag;
      91             :     double position;
      92             :     from >> position;
      93             :     //
      94         310 :     while (tag != "fahrzeugklassen") {
      95         310 :         tag = myRead(from);
      96             :     }
      97         155 :     std::vector<int> assignedVehicleTypes = parseAssignedVehicleTypes(from, "N/A");
      98             :     //
      99         155 :     NIVissimTL::dictionary(lsaid); // !!! check whether someting is really done here
     100             :     NIVissimTL::NIVissimTLSignal* signal =
     101             :         new NIVissimTL::NIVissimTLSignal(id, name, groupids, edgeid,
     102         155 :                                          laneno, position, assignedVehicleTypes);
     103         155 :     if (!NIVissimTL::NIVissimTLSignal::dictionary(lsaid, id, signal)) {
     104           0 :         throw 1; // !!!
     105             :     }
     106             :     return true;
     107             : }
     108             : 
     109             : 
     110             : /****************************************************************************/

Generated by: LCOV version 1.14