#include <ParameterGroup.hpp>
|
| ParameterGroup () |
|
| ParameterGroup (const std::string &path, const ParameterGroup *parent, const bool enable_output) |
|
virtual | ~ParameterGroup () |
|
virtual std::string | getTag () const |
| This function returns a string describing the ParameterMapItem. More...
|
|
template<typename StringArray > |
| ParameterGroup (int argc, StringArray argv, const bool verify_syntax=true, const bool enabled_output=true) |
| A constructor typically used to initialize a ParameterGroup from command-line arguments. More...
|
|
bool | has (const std::string &name) const |
| This method checks if there is something with name name in the parameter gropup. More...
|
|
template<typename T > |
T | get (const std::string &name) const |
| This method is used to read a parameter from the parameter group. More...
|
|
template<typename T , class Requirement > |
T | get (const std::string &name, const Requirement &) const |
|
template<typename T > |
T | getDefault (const std::string &name, const T &default_value) const |
| This method is used to read a parameter from the parameter group. More...
|
|
template<typename T , class Requirement > |
T | getDefault (const std::string &name, const T &default_value, const Requirement &r) const |
|
ParameterGroup | getGroup (const std::string &name) const |
| This method returns the parameter group given by name, i.e. it is an alias of get<ParameterGroup>(). More...
|
|
void | disableOutput () |
| Disables the output from get, getDefault and getGroup. By default, such output is enabled. More...
|
|
void | enableOutput () |
| Enables the output from get, getDefault and getGroup. By default, such output is enabled. More...
|
|
bool | isOutputEnabled () const |
| Returs true if and only if output from get, getDefault and getGroup is enabled. More...
|
|
void | readParam (const std::string ¶m_filename) |
| Reads the contents of the param file specified by param_filename into this ParameterGroup. More...
|
|
void | writeParam (const std::string ¶m_filename) const |
| Writes this ParameterGroup into a param file specified by param_filename. More...
|
|
void | writeParamToStream (std::ostream &stream) const |
| Writes this ParameterGroup to a stream. More...
|
|
template<typename T > |
void | get (const char *name, T &value, const T &default_value) const |
| vki param interface - deprecated More...
|
|
template<typename T > |
void | get (const char *name, T &value) const |
| vki param interface - deprecated More...
|
|
bool | anyUnused () const |
| Return true if any parameters are unused. More...
|
|
void | displayUsage (bool used_params=false) const |
| Shows which parameters which are used or unused. More...
|
|
std::string | path () const |
| Returns the path of the parameter group. More...
|
|
void | insert (const std::string &name, const std::shared_ptr< ParameterMapItem > &data) |
| Insert a new item into the group. More...
|
|
void | insertParameter (const std::string &name, const std::string &value) |
| Insert a new parameter item into the group. More...
|
|
const std::vector< std::string > & | unhandledArguments () const |
| Unhandled arguments from command line parsing. More...
|
|
template<> |
std::string | to_string (const bool &b) |
|
template<> |
std::string | to_string (const ParameterGroup &) |
|
void | setUsed () const |
|
bool | used () const |
|
ParameterGroup is a class that is used to provide run-time parameters. The standard use of the class is to call create it with the (int argc, char** argv) constructor (where the arguments are those given by main). This parses the command line, where each token either A) specifies a parameter (by a "param=value" token). B) specifies a param file to be read (by a "filename.param" token). After the tokens are parsed they are stored in a tree structure in the ParameterGroup object; it is worth mentioning that parameters are inherited in this tree structure. Thus, if `‘grid\_prefix’' is given a value in the root node, this value will be visible in all parts of the tree (unless the parameter is overwritten in a subtree). Applications using this ParameterGroup objects will usually write out a message for each node in the three that is used by the application; this is one way to determine valid parameters.
Parameters specified as "param=value" on the command line
To specify a parameter on the command line, you must know where in the tree the parameter resides. The syntax for specifying parameters on the command line given an application called `‘simulator’' is simulator param1=value grp/param2=value grp''. If the same parameters are specified multiple times on the command line, only the last will be used. Thus an application named simulator'' run with the following command simulator param=value1 param=value2 will use value2 as the value of `‘param’'.
param files
A param file consists of multiple lienes, where each line consists of "param=value". This syntax is identical to the one for parameters specified on the command line.
◆ ParameterGroup() [1/3]
Opm::ParameterGroup::ParameterGroup |
( |
| ) |
|
◆ ParameterGroup() [2/3]
◆ ~ParameterGroup()
virtual Opm::ParameterGroup::~ParameterGroup |
( |
| ) |
|
|
virtual |
◆ ParameterGroup() [3/3]
template<typename StringArray >
Opm::ParameterGroup::ParameterGroup |
( |
int |
argc, |
|
|
StringArray |
argv, |
|
|
const bool |
verify_syntax = true , |
|
|
const bool |
enabled_output = true |
|
) |
| |
A constructor typically used to initialize a ParameterGroup from command-line arguments.
It is required that argv[0] is the program name, while if 0 < i < argc, then argv[i] is either the name of a parameter file or parametername=value.
- Parameters
-
argc | is the number of command-line arguments, including the name of the executable. |
argv | is an array of char*, each of which is a command line argument. |
verify_syntax | If true (default), then it is an error to pass arguments that cannot be handled by the ParameterGroup, or an empty argument list. If false, such arguments are stored and can be retrieved later with unhandledArguments(). |
enable_output | Whether to enable output or not. |
References Catch::cerr().
◆ anyUnused()
bool Opm::ParameterGroup::anyUnused |
( |
| ) |
const |
Return true if any parameters are unused.
◆ disableOutput()
void Opm::ParameterGroup::disableOutput |
( |
| ) |
|
Disables the output from get, getDefault and getGroup. By default, such output is enabled.
◆ displayUsage()
void Opm::ParameterGroup::displayUsage |
( |
bool |
used_params = false | ) |
const |
Shows which parameters which are used or unused.
◆ enableOutput()
void Opm::ParameterGroup::enableOutput |
( |
| ) |
|
Enables the output from get, getDefault and getGroup. By default, such output is enabled.
◆ get() [1/4]
template<typename T >
void Opm::ParameterGroup::get |
( |
const char * |
name, |
|
|
T & |
value |
|
) |
| const |
|
inline |
◆ get() [2/4]
template<typename T >
void Opm::ParameterGroup::get |
( |
const char * |
name, |
|
|
T & |
value, |
|
|
const T & |
default_value |
|
) |
| const |
|
inline |
◆ get() [3/4]
template<typename T >
T Opm::ParameterGroup::get |
( |
const std::string & |
name | ) |
const |
|
inline |
This method is used to read a parameter from the parameter group.
NOTE: If the reading of the parameter fails, then this method throws an appropriate exception.
- Parameters
-
name | is the name of the parameter in question. |
- Returns
- The value associated with then name in this parameter group.
References name.
Referenced by get(), and example::identifyResultSet().
◆ get() [4/4]
template<typename T , class Requirement >
T Opm::ParameterGroup::get |
( |
const std::string & |
name, |
|
|
const Requirement & |
r |
|
) |
| const |
|
inline |
◆ getDefault() [1/2]
template<typename T >
T Opm::ParameterGroup::getDefault |
( |
const std::string & |
name, |
|
|
const T & |
default_value |
|
) |
| const |
|
inline |
This method is used to read a parameter from the parameter group.
NOTE: If the reading of the parameter fails, then either a) this method returns default_value if there was no parameter with name name in the parameter group or b) this method throws an appropriate exception.
- Parameters
-
name | is the name of the parameter in question. |
default_value | the default value of the parameter in question. |
- Returns
- The value associated with this name in this parameter group.
References name.
Referenced by getDefault(), and example::Setup::Setup().
◆ getDefault() [2/2]
template<typename T , class Requirement >
T Opm::ParameterGroup::getDefault |
( |
const std::string & |
name, |
|
|
const T & |
default_value, |
|
|
const Requirement & |
r |
|
) |
| const |
|
inline |
◆ getGroup()
This method returns the parameter group given by name, i.e. it is an alias of get<ParameterGroup>().
- Parameters
-
name | is the name of the parameter group sought. |
- Returns
- the parameter group sought.
◆ getTag()
virtual std::string Opm::ParameterGroup::getTag |
( |
| ) |
const |
|
virtual |
◆ has()
This method checks if there is something with name name in the parameter gropup.
- Parameters
-
name | is the name of the parameter. |
- Returns
- true if
name is the name of something in the parameter group, false otherwise.
Referenced by example::identifyResultSet().
◆ insert()
Insert a new item into the group.
◆ insertParameter()
Insert a new parameter item into the group.
◆ isOutputEnabled()
bool Opm::ParameterGroup::isOutputEnabled |
( |
| ) |
const |
Returs true if and only if output from get, getDefault and getGroup is enabled.
- Returns
- true if and only if output from get, getDefault and getGroup is enabled.
◆ path()
◆ readParam()
void Opm::ParameterGroup::readParam |
( |
const std::string & |
param_filename | ) |
|
Reads the contents of the param file specified by param_filename into this ParameterGroup.
NOTE: A param file contains lines on the form 'a/b/c=d'. (e.g. c is a Parameter in the ParameterGroup b, and b is a ParameterGroup in the ParameterGroup a) while '=' separates the name from the value (e.g. the value of the parameter c above will be d). NOTE: A param file does not store any type information about its values.
- Parameters
-
param_filename | is the name of a param file. |
◆ setUsed()
void Opm::ParameterMapItem::setUsed |
( |
| ) |
const |
|
inlineinherited |
◆ to_string() [1/2]
◆ to_string() [2/2]
◆ unhandledArguments()
const std::vector< std::string > & Opm::ParameterGroup::unhandledArguments |
( |
| ) |
const |
Unhandled arguments from command line parsing.
◆ used()
bool Opm::ParameterMapItem::used |
( |
| ) |
const |
|
inlineinherited |
◆ writeParam()
void Opm::ParameterGroup::writeParam |
( |
const std::string & |
param_filename | ) |
const |
Writes this ParameterGroup into a param file specified by param_filename.
- Parameters
-
param_filename | is the name of a param file. |
◆ writeParamToStream()
void Opm::ParameterGroup::writeParamToStream |
( |
std::ostream & |
stream | ) |
const |
Writes this ParameterGroup to a stream.
- Parameters
-
stream | is the stream to write to. |
The documentation for this class was generated from the following files:
|