Project Malmo  0.37.0
ParameterSet.h
1 // --------------------------------------------------------------------------------------------------
2 // Copyright (c) 2016 Microsoft Corporation
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 // associated documentation files (the "Software"), to deal in the Software without restriction,
6 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all copies or
11 // substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 // --------------------------------------------------------------------------------------------------
19 
20 #ifndef _PARAMETERSET_H_
21 #define _PARAMETERSET_H_
22 
23 // Boost:
24 #include <boost/property_tree/ptree.hpp>
25 
26 // STL:
27 #include <string>
28 #include <vector>
29 
30 namespace malmo
31 {
35  {
36  public:
39 
42  ParameterSet(const boost::property_tree::ptree parameters);
43 
46  ParameterSet(const std::string& json);
47 
50  std::string toJson();
51 
55  void set(const std::string& key, const std::string& value);
56 
60  std::string get(const std::string& key) const;
61 
65  void setInt(const std::string& key, const int value);
66 
70  int getInt(const std::string& key) const;
71 
75  void setDouble(const std::string& key, const double value);
76 
80  double getDouble(const std::string& key) const;
81 
85  void setBool(const std::string& key, const bool value);
86 
90  bool getBool(const std::string& key) const;
91 
94  std::vector<std::string> keys() const;
95 
98  void setIterationCount(const int iteration_count);
99 
102  int getIterationCount() const;
103 
104  private:
105  boost::property_tree::ptree parameters;
106  int iteration_count;
107  };
108 }
109 
110 #endif
Class which contains a list of key/value parameters for a mission.
Definition: ParameterSet.h:35
void set(const std::string &key, const std::string &value)
Sets the value of a key as a string.
void setBool(const std::string &key, const bool value)
Sets the value of a key as a boolean.
int getIterationCount() const
Gets the number of iterations that these parameters should be tested.
bool getBool(const std::string &key) const
Gets the value of a key as a boolean.
double getDouble(const std::string &key) const
Gets the value of a key as a double.
std::string toJson()
Returns a JSON representation of the parameter set.
void setIterationCount(const int iteration_count)
Sets the number of iterations that these parameters should be tested.
ParameterSet()
Constructs a parameter set.
int getInt(const std::string &key) const
Gets the value of a key as an integer.
std::string get(const std::string &key) const
Gets the value of a key as a string.
void setDouble(const std::string &key, const double value)
Sets the value of a key as a double.
void setInt(const std::string &key, const int value)
Sets the value of a key as an integer.
ParameterSet(const boost::property_tree::ptree parameters)
Constructs a parameter set using the provided property tree.
ParameterSet(const std::string &json)
Constructs a parameter set from the provided JSON string.
std::vector< std::string > keys() const
Gets the keys in the parameter set.