SUMO - Simulation of Urban MObility
PCTypeMap.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A storage for type mappings
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2005-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <map>
36 #include "PCTypeMap.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43  myDefaultType.id = oc.getString("type");
45  myDefaultType.layer = oc.getFloat("layer");
46  myDefaultType.discard = oc.getBool("discard");
47  myDefaultType.allowFill = oc.getBool("fill");
48  myDefaultType.prefix = oc.getString("prefix");
49 }
50 
51 
53 
54 
55 bool
56 PCTypeMap::add(const std::string& id, const std::string& newid,
57  const std::string& color, const std::string& prefix,
58  double layer, bool discard, bool allowFill) {
59  if (has(id)) {
60  return false;
61  }
62  TypeDef td;
63  td.id = newid;
64  td.color = RGBColor::parseColor(color);
65  td.layer = layer;
66  td.discard = discard;
67  td.allowFill = allowFill;
68  td.prefix = prefix;
69  myTypes[id] = td;
70  return true;
71 }
72 
73 
74 const PCTypeMap::TypeDef&
75 PCTypeMap::get(const std::string& id) {
76  return myTypes.find(id)->second;
77 }
78 
79 
80 bool
81 PCTypeMap::has(const std::string& id) {
82  return myTypes.find(id) != myTypes.end();
83 }
84 
85 
86 
87 /****************************************************************************/
88 
std::string id
The new type id to use.
Definition: PCTypeMap.h:68
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:168
A single definition of values that shall be used for a given type.
Definition: PCTypeMap.h:66
double layer
The layer to use.
Definition: PCTypeMap.h:74
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
TypeDef myDefaultType
Definition: PCTypeMap.h:123
bool discard
Information whether polygons of this type shall be discarded.
Definition: PCTypeMap.h:76
RGBColor color
The color to use.
Definition: PCTypeMap.h:70
const TypeDef & get(const std::string &id)
Returns a type definition.
Definition: PCTypeMap.cpp:75
bool has(const std::string &id)
Returns the information whether the named type is known.
Definition: PCTypeMap.cpp:81
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
PCTypeMap(const OptionsCont &oc)
Constructor. The default type is constructed based on the given options.
Definition: PCTypeMap.cpp:42
~PCTypeMap()
Destructor.
Definition: PCTypeMap.cpp:52
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string prefix
The prefix to use.
Definition: PCTypeMap.h:72
A storage for options typed value containers)
Definition: OptionsCont.h:99
std::map< std::string, TypeDef > myTypes
A map of type names to type definitions.
Definition: PCTypeMap.h:121
bool add(const std::string &id, const std::string &newid, const std::string &color, const std::string &prefix, double layer, bool discard, bool allowFill)
Adds a type definition.
Definition: PCTypeMap.cpp:56
bool allowFill
Information whether polygons of this type can be filled.
Definition: PCTypeMap.h:78