SUMO - Simulation of Urban MObility
Parameterised.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A super class for objects with additional parameters
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2002-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef Parameterised_h
24 #define Parameterised_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <map>
37 #include <string>
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class OutputDevice;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
52 public:
55  Parameterised();
56 
57 
61  Parameterised(const std::map<std::string, std::string>& mapArg);
62 
63 
66 
67 
68 
73  void addParameter(const std::string& key, const std::string& value);
74 
75 
79  void addParameter(const std::map<std::string, std::string>& mapArg);
80 
81 
85  void addParameter(const Parameterised& p);
86 
87 
92  bool knowsParameter(const std::string& key) const;
93 
94 
100  const std::string& getParameter(const std::string& key, const std::string& defaultValue) const;
101 
102 
108  double getDouble(const std::string& key, const double defaultValue) const;
109 
110 
113  void clearParameter();
114 
115 
119  const std::map<std::string, std::string>& getMap() const {
120  return myMap;
121  }
122 
123  void writeParams(OutputDevice& out) const;
124 
125 
126 private:
128  std::map<std::string, std::string> myMap;
129 
130 };
131 
132 
133 #endif
134 
135 /****************************************************************************/
136 
std::map< std::string, std::string > myMap
The key->value map.
void writeParams(OutputDevice &out) const
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
~Parameterised()
Destructor.
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
Parameterised()
Constructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void clearParameter()
Clears the parameter map.