Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
PCTypeMap.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2005-2023 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/****************************************************************************/
20// A storage for type mappings
21/****************************************************************************/
22#include <config.h>
23
24#include <string>
25#include <map>
27#include "PCTypeMap.h"
28
29
30// ===========================================================================
31// method definitions
32// ===========================================================================
34 myDefaultType.id = oc.getString("type");
36 myDefaultType.layer = oc.getFloat("layer");
37 myDefaultType.discard = oc.getBool("discard");
38 myDefaultType.allowFill = oc.getBool("fill");
39 myDefaultType.prefix = oc.getString("prefix");
40}
41
42
44
45
46bool
47PCTypeMap::add(const std::string& id, const std::string& newid,
48 const std::string& color, const std::string& prefix,
49 double layer, double angle, const std::string& imgFile,
50 bool discard, bool allowFill) {
51 if (has(id)) {
52 return false;
53 }
54 TypeDef td;
55 td.id = newid;
56 td.color = RGBColor::parseColor(color);
57 td.layer = layer;
58 td.angle = angle;
59 td.imgFile = imgFile;
60 td.discard = discard;
61 td.allowFill = allowFill;
62 td.prefix = prefix;
63 myTypes[id] = td;
64 return true;
65}
66
67
69PCTypeMap::get(const std::string& id) {
70 return myTypes.find(id)->second;
71}
72
73
74bool
75PCTypeMap::has(const std::string& id) {
76 return myTypes.find(id) != myTypes.end();
77}
78
79
80/****************************************************************************/
A storage for options typed value containers)
Definition OptionsCont.h:89
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
~PCTypeMap()
Destructor.
Definition PCTypeMap.cpp:43
PCTypeMap(const OptionsCont &oc)
Constructor. The default type is constructed based on the given options.
Definition PCTypeMap.cpp:33
const TypeDef & get(const std::string &id)
Returns a type definition.
Definition PCTypeMap.cpp:69
TypeDef myDefaultType
Definition PCTypeMap.h:125
std::map< std::string, TypeDef > myTypes
A map of type names to type definitions.
Definition PCTypeMap.h:123
bool has(const std::string &id)
Returns the information whether the named type is known.
Definition PCTypeMap.cpp:75
bool add(const std::string &id, const std::string &newid, const std::string &color, const std::string &prefix, double layer, double angle, const std::string &imgFile, bool discard, bool allowFill)
Adds a type definition.
Definition PCTypeMap.cpp:47
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition RGBColor.cpp:239
A single definition of values that shall be used for a given type.
Definition PCTypeMap.h:56
bool discard
Information whether polygons of this type shall be discarded.
Definition PCTypeMap.h:70
std::string prefix
The prefix to use.
Definition PCTypeMap.h:62
double layer
The layer to use.
Definition PCTypeMap.h:64
bool allowFill
Information whether polygons of this type can be filled.
Definition PCTypeMap.h:72
double angle
The angle to use.
Definition PCTypeMap.h:66
std::string imgFile
The image file to use.
Definition PCTypeMap.h:68
std::string id
The new type id to use.
Definition PCTypeMap.h:58
RGBColor color
The color to use.
Definition PCTypeMap.h:60