LCOV - code coverage report
Current view: top level - src/polyconvert - PCTypeMap.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 24 24
Test Date: 2024-12-21 15:45:41 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2005-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    PCTypeMap.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Mon, 05 Dec 2005
      19              : ///
      20              : // A storage for type mappings
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <string>
      25              : #include <map>
      26              : #include "utils/options/OptionsCont.h"
      27              : #include "PCTypeMap.h"
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // method definitions
      32              : // ===========================================================================
      33           43 : PCTypeMap::PCTypeMap(const OptionsCont& oc) {
      34           43 :     myDefaultType.id = oc.getString("type");
      35           43 :     myDefaultType.color = RGBColor::parseColor(oc.getString("color"));
      36           43 :     myDefaultType.icon = oc.getString("icon");
      37           43 :     myDefaultType.layer = oc.getFloat("layer");
      38           43 :     myDefaultType.discard = oc.getBool("discard");
      39           44 :     myDefaultType.allowFill = oc.getBool("fill") ? Filltype::FILL : Filltype::NOFILL;
      40           43 :     myDefaultType.prefix = oc.getString("prefix");
      41           43 : }
      42              : 
      43              : 
      44           43 : PCTypeMap::~PCTypeMap() {}
      45              : 
      46              : 
      47              : bool
      48         1176 : PCTypeMap::add(const std::string& id, const std::string& newid, const std::string& color,
      49              :                const std::string& prefix, const std::string& icon, double layer,
      50              :                double angle, const std::string& imgFile, bool discard, Filltype allowFill) {
      51         1176 :     if (has(id)) {
      52              :         return false;
      53              :     }
      54         1176 :     TypeDef td;
      55              :     td.id = newid;
      56         2352 :     td.color = RGBColor::parseColor(color);
      57              :     td.icon = icon;
      58         1176 :     td.layer = layer;
      59         1176 :     td.angle = angle;
      60              :     td.imgFile = imgFile;
      61         1176 :     td.discard = discard;
      62         1176 :     td.allowFill = allowFill;
      63              :     td.prefix = prefix;
      64         1176 :     myTypes[id] = td;
      65              :     return true;
      66         1176 : }
      67              : 
      68              : 
      69              : const PCTypeMap::TypeDef&
      70         9100 : PCTypeMap::get(const std::string& id) {
      71         9100 :     return myTypes.find(id)->second;
      72              : }
      73              : 
      74              : 
      75              : bool
      76       119945 : PCTypeMap::has(const std::string& id) {
      77       119945 :     return myTypes.find(id) != myTypes.end();
      78              : }
      79              : 
      80              : 
      81              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1