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-2015 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 #ifdef CHECK_MEMORY_LEAKS
39 #include <foreign/nvwa/debug_new.h>
40 #endif // CHECK_MEMORY_LEAKS
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  myDefaultType.id = oc.getString("type");
49  myDefaultType.layer = oc.getInt("layer");
50  myDefaultType.discard = oc.getBool("discard");
51  myDefaultType.allowFill = oc.getBool("fill");
52  myDefaultType.prefix = oc.getString("prefix");
53 }
54 
55 
57 
58 
59 bool
60 PCTypeMap::add(const std::string& id, const std::string& newid,
61  const std::string& color, const std::string& prefix,
62  int layer, bool discard, bool allowFill) {
63  if (has(id)) {
64  return false;
65  }
66  TypeDef td;
67  td.id = newid;
68  td.color = RGBColor::parseColor(color);
69  td.layer = layer;
70  td.discard = discard;
71  td.allowFill = allowFill;
72  td.prefix = prefix;
73  myTypes[id] = td;
74  return true;
75 }
76 
77 
78 const PCTypeMap::TypeDef&
79 PCTypeMap::get(const std::string& id) {
80  return myTypes.find(id)->second;
81 }
82 
83 
84 bool
85 PCTypeMap::has(const std::string& id) {
86  return myTypes.find(id) != myTypes.end();
87 }
88 
89 
90 
91 /****************************************************************************/
92 
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:172
A single definition of values that shall be used for a given type.
Definition: PCTypeMap.h:66
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
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const TypeDef & get(const std::string &id)
Returns a type definition.
Definition: PCTypeMap.cpp:79
bool add(const std::string &id, const std::string &newid, const std::string &color, const std::string &prefix, int layer, bool discard, bool allowFill)
Adds a type definition.
Definition: PCTypeMap.cpp:60
bool has(const std::string &id)
Returns the information whether the named type is known.
Definition: PCTypeMap.cpp:85
PCTypeMap(const OptionsCont &oc)
Constructor. The default type is constructed based on the given options.
Definition: PCTypeMap.cpp:46
~PCTypeMap()
Destructor.
Definition: PCTypeMap.cpp:56
std::string prefix
The prefix to use.
Definition: PCTypeMap.h:72
A storage for options typed value containers)
Definition: OptionsCont.h:108
std::map< std::string, TypeDef > myTypes
A map of type names to type definitions.
Definition: PCTypeMap.h:121
int layer
The layer to use.
Definition: PCTypeMap.h:74
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool allowFill
Information whether polygons of this type can be filled.
Definition: PCTypeMap.h:78