Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A super class for objects with additional parameters
19 /****************************************************************************/
20 #ifndef Parameterised_h
21 #define Parameterised_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 
28 #include <map>
29 #include <string>
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class OutputDevice;
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
44 public:
46  Parameterised();
47 
51  Parameterised(const std::map<std::string, std::string>& mapArg);
52 
55 
60  void setParameter(const std::string& key, const std::string& value);
61 
65  void unsetParameter(const std::string& key);
66 
70  void updateParameter(const std::map<std::string, std::string>& mapArg);
71 
76  bool knowsParameter(const std::string& key) const;
77 
83  const std::string getParameter(const std::string& key, const std::string& defaultValue = "") const;
84 
90  double getDouble(const std::string& key, const double defaultValue) const;
91 
93  void clearParameter();
94 
96  const std::map<std::string, std::string>& getParametersMap() const;
97 
99  void writeParams(OutputDevice& device) const;
100 
101 private:
103  std::map<std::string, std::string> myMap;
104 };
105 
106 
107 #endif
108 
109 /****************************************************************************/
110 
std::map< std::string, std::string > myMap
The key->value map.
void unsetParameter(const std::string &key)
Removes a parameter.
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:43
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
Parameterised()
Constructor.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void clearParameter()
Clears the parameter map.