SUMO - Simulation of Urban MObility
Parameterised.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // A super class for objects with additional parameters
21 /****************************************************************************/
22 #ifndef Parameterised_h
23 #define Parameterised_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <string>
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class OutputDevice;
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 public:
54  Parameterised();
55 
56 
60  Parameterised(const std::map<std::string, std::string>& mapArg);
61 
62 
65 
66 
67 
72  void setParameter(const std::string& key, const std::string& value);
73 
77  void unsetParameter(const std::string& key);
78 
79 
83  void updateParameter(const std::map<std::string, std::string>& mapArg);
84 
85 
90  bool knowsParameter(const std::string& key) const;
91 
92 
98  const std::string getParameter(const std::string& key, const std::string& defaultValue = "") const;
99 
100 
106  double getDouble(const std::string& key, const double defaultValue) const;
107 
108 
111  void clearParameter();
112 
113 
117  const std::map<std::string, std::string>& getMap() const {
118  return myMap;
119  }
120 
121  void writeParams(OutputDevice& out) const;
122 
123 
124 private:
126  std::map<std::string, std::string> myMap;
127 
128 };
129 
130 
131 #endif
132 
133 /****************************************************************************/
134 
std::map< std::string, std::string > myMap
The key->value map.
void unsetParameter(const std::string &key)
Removes a parameter.
void writeParams(OutputDevice &out) const
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
void updateParameter(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
~Parameterised()
Destructor.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
Parameterised()
Constructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
void clearParameter()
Clears the parameter map.