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-2018 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 #include <config.h>
28 
29 #include <map>
30 #include <string>
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class OutputDevice;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
47  Parameterised();
48 
52  Parameterised(const std::map<std::string, std::string>& mapArg);
53 
56 
61  void setParameter(const std::string& key, const std::string& value);
62 
66  void unsetParameter(const std::string& key);
67 
71  void updateParameter(const std::map<std::string, std::string>& mapArg);
72 
77  bool knowsParameter(const std::string& key) const;
78 
84  const std::string getParameter(const std::string& key, const std::string& defaultValue = "") const;
85 
91  double getDouble(const std::string& key, const double defaultValue) const;
92 
94  void clearParameter();
95 
97  const std::map<std::string, std::string>& getParametersMap() const;
98 
100  void writeParams(OutputDevice& device) const;
101 
102 private:
104  std::map<std::string, std::string> myMap;
105 };
106 
107 
108 #endif
109 
110 /****************************************************************************/
111 
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:44
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.