NEML2 2.0.0
|
Metadata associated with this option
#include <OptionSet.h>
Public Member Functions | |
bool | operator== (const Metadata &other) const |
bool | operator!= (const Metadata &other) const |
Public Attributes | |
std::string | name = "" |
Name of the option. | |
std::string | type = "" |
Type of the option. | |
FType | ftype = FType::NONE |
Option's role in defining the function. | |
std::string | doc = "" |
Option's doc string. | |
bool | suppressed = false |
Whether this option is suppressed. | |
bool | user_specified = false |
Whether this option has been specified by the user from the input file. | |
std::string doc = "" |
Option's doc string.
When we build the documentation for NEML2, we automatically extract the syntax and convert it to a markdown file. The syntax of NEML2 is just the collection of expected options of all the registered objects. Doxygen will then render the markdown syntax to the target output format, e.g., html, tex, etc. This implies that the docstring can contain anything that the Doxygen's markdown renderer can understand. For more information, see https://www.doxygen.nl/manual/markdown.html
FType ftype = FType::NONE |
Option's role in defining the function.
Since the syntax documentation is automatically extracted from options defined by neml2::NEML2Object::expected_options, there is no way for us to tell, at the time of syntax extraction, whether a variable name is used for the model's input variable, output variable. This metadata information defines such missing information. See neml2::FType for enum values.
std::string name = "" |
Name of the option.
For example, in a HIT input file, this is the field name that appears on the left-hand side
where "bar" is the option name
Whether this option is suppressed.
By default an option is not suppressed. However, it is sometimes desirable for a derived object to suppress certain option. A suppressed option cannot be modified by the user. It is up to the specific Parser to decide what happens when a user attempts to set a suppressed option, e.g., the parser can choose to throw an exception, print a warning and accept it, or print a warning and ignores it.
std::string type = "" |
Type of the option.
We use RTTI to determine the type of the option. Most importantly, two options are considered different if they have different types, even if they have the same name. For example, if you specify an option of name "foo" of type int
as an expected option, later if you attempt to retrieve an option of name "foo" but of type string
, an exception will be thrown saying that the option does not exist.
Whether this option has been specified by the user from the input file.
In occasions, options are optional. This field is used to determine whether the user has specified the option. If the user has not specified the option, the default (sometimes undefined) value is used. It is therefore important to check this flag before retrieving optional options.