Alsvinn  0.5.3
The fast FVM simulator with UQ support
Parameters.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 #include <boost/property_tree/ptree.hpp>
18 #include <vector>
19 #include <map>
20 namespace alsutils {
21 namespace parameters {
22 
24 class Parameters {
25 public:
26  Parameters(const boost::property_tree::ptree& ptree);
27 
30  Parameters(const std::map<std::string, std::string>& values);
31 
32 
33  double getDouble(const std::string& name) const;
34  int getInteger(const std::string& name) const;
35  std::string getString(const std::string& name) const;
36 
37  bool contains(const std::string& name) const;
38 
39  std::vector<std::string> getStringVectorFromString(const std::string& name)
40  const;
41 
42  std::vector<std::string> getKeys() const;
43 
44  void addIntegerParameter(const std::string& name, int i);
45  void addDoubleParameter(const std::string& name, double i);
46  void addStringParameter(const std::string& name, std::string value);
47  void addVectorParameter(const std::string& name,
48  const std::vector<std::string>& values);
49 
50 
52  static Parameters empty();
53 private:
54  boost::property_tree::ptree ptree;
55 
56 };
57 } // namespace parameters
58 } // namespace alsutils
std::vector< std::string > getKeys() const
Definition: Parameters.cpp:58
bool contains(const std::string &name) const
Definition: Parameters.cpp:44
simulator::SimulatorParameters & parameters
Definition: CellComputerFactory.cpp:60
Holds general parameters based on a boost::property tree.
Definition: Parameters.hpp:24
void addIntegerParameter(const std::string &name, int i)
Definition: Parameters.cpp:68
void addVectorParameter(const std::string &name, const std::vector< std::string > &values)
Definition: Parameters.cpp:81
double getDouble(const std::string &name) const
Definition: Parameters.cpp:32
Parameters(const boost::property_tree::ptree &ptree)
Definition: Parameters.cpp:21
std::string name
Definition: EquationParameterFactory.cpp:39
void addDoubleParameter(const std::string &name, double i)
Definition: Parameters.cpp:72
Various utilities for mpi and cuda.
Definition: Factory.hpp:3
int getInteger(const std::string &name) const
Definition: Parameters.cpp:36
void addStringParameter(const std::string &name, std::string value)
Definition: Parameters.cpp:76
static Parameters empty()
Returns an empty parameter instance, when you don&#39;t want to give any parameters.
Definition: Parameters.cpp:87
std::string getString(const std::string &name) const
Definition: Parameters.cpp:40
std::vector< std::string > getStringVectorFromString(const std::string &name) const
Definition: Parameters.cpp:48