SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2005-2014 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 = true;
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