36#ifndef OPM_PARAMETERGROUP_HEADER
37#define OPM_PARAMETERGROUP_HEADER
44#include <opm/common/utility/parameters/ParameterMapItem.hpp>
45#include <opm/common/utility/parameters/ParameterRequirement.hpp>
83 struct NotFoundException :
public std::exception {};
84 struct WrongTypeException :
public std::exception {};
85 struct ConversionFailedException :
public std::exception {};
88 struct RequirementFailedException :
public std::exception {};
92 const bool enable_output);
95 ~ParameterGroup()
override;
96 std::string getTag()
const override;
114 template <
typename StringArray>
115 ParameterGroup(
int argc, StringArray argv,
const bool verify_syntax =
true,
116 const bool enable_output =
true);
124 bool has(
const std::string& name)
const;
136 T
get(
const std::string& name)
const;
138 template<
typename T,
class Requirement>
139 T
get(
const std::string& name,
const Requirement&)
const;
158 const T& default_value)
const;
160 template<
typename T,
class Requirement>
162 const T& default_value,
163 const Requirement& r)
const;
200 void readParam(
const std::string& param_filename);
206 void writeParam(
const std::string& param_filename)
const;
216 void get(
const char* name, T& value,
const T& default_value)
const {
222 void get(
const char* name, T& value)
const {
223 value = this->
get<T>(name);
233 const std::string&
path()
const;
237 const std::shared_ptr<ParameterMapItem>& data);
240 void insertParameter(
const std::string& name,
const std::string& value);
246 typedef std::shared_ptr<ParameterMapItem> data_type;
247 typedef std::pair<std::string, data_type> pair_type;
248 typedef std::map<std::string, data_type> map_type;
253 bool output_is_enabled_;
254 std::vector<std::string> unhandled_arguments_;
256 template<
typename T,
class Requirement>
257 T translate(
const pair_type& data,
const Requirement& chk)
const;
258 template <
typename StringArray>
259 void parseCommandLineArguments(
int argc, StringArray argv,
bool verify_syntax);
260 void recursiveSetIsOutputEnabled(
bool output_is_enabled);
263 template <
typename T>
264 static std::string to_string(
const T& val);
265 static std::pair<std::string, std::string>
266 filename_split(
const std::string& filename);
270#include <opm/common/utility/parameters/ParameterGroup_impl.hpp>
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
bool anyUnused() const
Return true if any parameters are unused.
Definition ParameterGroup.cpp:266
bool has(const std::string &name) const
This method checks if there is something with name name in the parameter gropup.
T getDefault(const std::string &name, const T &default_value) const
This method is used to read a parameter from the parameter group.
const std::vector< std::string > & unhandledArguments() const
Unhandled arguments from command line parsing.
Definition ParameterGroup.cpp:327
void writeParam(const std::string ¶m_filename) const
Writes this ParameterGroup into a param file specified by param_filename.
Definition ParameterGroup.cpp:139
T get(const std::string &name) const
This method is used to read a parameter from the parameter group.
const std::string & path() const
Returns the path of the parameter group.
void disableOutput()
Disables the output from get, getDefault and getGroup.
Definition ParameterGroup.cpp:304
void insertParameter(const std::string &name, const std::string &value)
Insert a new parameter item into the group.
Definition ParameterGroup.cpp:201
void writeParamToStream(std::ostream &stream) const
Writes this ParameterGroup to a stream.
Definition ParameterGroup.cpp:149
void enableOutput()
Enables the output from get, getDefault and getGroup.
Definition ParameterGroup.cpp:308
void insert(const std::string &name, const std::shared_ptr< ParameterMapItem > &data)
Insert a new item into the group.
void displayUsage(bool used_params=false) const
Shows which parameters which are used or unused.
Definition ParameterGroup.cpp:286
bool isOutputEnabled() const
Returs true if and only if output from get, getDefault and getGroup is enabled.
Definition ParameterGroup.cpp:312
void readParam(const std::string ¶m_filename)
Reads the contents of the param file specified by param_filename into this ParameterGroup.
Definition ParameterGroup.cpp:107
ParameterGroup(int argc, StringArray argv, const bool verify_syntax=true, const bool enable_output=true)
ParameterGroup is a class that is used to provide run-time parameters.
Definition ParameterGroup_impl.hpp:113
ParameterGroup getGroup(const std::string &name) const
This method returns the parameter group given by name, i.e.
The parameter handlig system is structured as a tree, where each node inhertis from ParameterMapItem.
Definition ParameterMapItem.hpp:47