STORMM Source Documentation
|
One keyword found in a namelist, ready to store the namelist variable moniker, the type, and the value read from the input file. More...
#include <namelist_element.h>
Public Member Functions | |
const std::string & | getLabel () const |
Get the keyword for a namelist element, i.e. nstlim in Amber &ctrl. | |
const std::string & | getSubLabel (size_t index) const |
Get a sub-key for this element. | |
void | setPolicy (ExceptionResponse policy_in) |
Set the way that this Namelist element will respond if it encounters bad input. The member variable associated with this function is not passed down as part of the constructor argument list, and would be tedious for the developer to enter over and over, so it is passed down based on the NamelistEmulator's own setting by calling this function. | |
void | reportNamelistTypeProblem (const std::string &caller, const std::string &data_type) const |
Report an error based on an incorrect namelist element data type request. This is an assertion that debugs a program when a developer makes a mistake, not something that an end user should encounter, but it's helpful to have a more detailed description than assert() can provide. This always ends by throwing a runtime error and so is an acceptable way to fill a switch case. | |
int | getEntryCount () const |
Get the depth of the namelist element, the number of values that it stores. | |
InputStatus | getEstablishment (const std::string &member_key=std::string(""), int repeat_no=0) const |
Report whether a value has been assigned, read from input, to this namelist element. | |
bool | getRepeatableValueState () const |
Report whether an element accepts multiple values. | |
int | getTemplateSize () const |
Obtain the size of this namelist element's template (if it is a STRUCT) | |
void | badInputResponse (const std::string &errmsg, const char *caller) |
Respond to bad user input at the NamelistElement level, based on a policy handed down from a NamelistEmulator. This does not apply to developer-level mistakes, which always throw runtime errors. | |
void | addDefaultValue (const std::string &next_default) |
Include an additional value as a default setting for a particular keyword. This enables a single keyword to have a default series of values. The supplied value will be interpreted according to the type of the element. | |
NamelistElement (const std::string &keyword_in, NamelistType kind_in, const std::string &default_in=std::string(""), DefaultIsObligatory obligate=DefaultIsObligatory::NO, InputRepeats rep_in=InputRepeats::NO, const std::string &help_in=std::string("No description provided")) | |
Constructor for a non-STRUCT NamelistElement. | |
NamelistElement (const std::string keyword_in, const std::vector< std::string > &sub_keys_in, const std::vector< NamelistType > &sub_kinds_in, const std::vector< std::string > &default_list, DefaultIsObligatory obligate_list=DefaultIsObligatory::NO, InputRepeats rep_in=InputRepeats::NO, const std::string &help_in=std::string("No description provided"), const std::vector< std::string > &sub_help_in=std::vector< std::string >(1, "No description provided"), const std::vector< KeyRequirement > &template_requirements_in={}) | |
NamelistElement (const NamelistElement &original)=default | |
With no const members and only Standard Template Library components, the default copy and move constructors, as well as the copy and move assignment operators, are valid. | |
NamelistElement (NamelistElement &&original)=default | |
NamelistElement & | operator= (const NamelistElement &original)=default |
NamelistElement & | operator= (NamelistElement &&original)=default |
NamelistType | getKind () const |
Get the kind associated with a namelist element, i.e. nstlim is an INTEGER in Amber &ctrl. | |
NamelistType | getKind (const std::string &sub_key_query) const |
bool | getBoolValue (const std::string &member_key, int index) const |
Get the boolean value to which a namelist element has been set (this value is set to TRUE if the keyword was found in the namelist or collection of STRUCT sub-keys, FALSE if not). | |
bool | getBoolValue () const |
std::vector< bool > | getBoolValue (const std::string &member_key) const |
int | getIntValue (const std::string &member_key, int index) const |
Get the integer value to which a namelist element has been set (this value is read from the namelist input file, i.e. mdin). Descriptions of input parameters follow from getBoolValue(), above. | |
int | getIntValue (int index) const |
std::vector< int > | getIntValue (const std::string &member_key=std::string("")) const |
double | getRealValue (const std::string &member_key, int index) const |
Get the real value to which a namelist element has been set (this value is read from the namelist input file, i.e. mdin). Overloading and descriptions of input parameters follow from getIntegerValue() | |
double | getRealValue (int index) const |
std::vector< double > | getRealValue (const std::string &member_key=std::string("")) const |
const std::string & | getStringValue (const std::string &member_key, int index) const |
Get the string value to which a namelist element has been set (this value is read from the namelist input file, i.e. mdin) | |
const std::string & | getStringValue (int index) const |
std::vector< std::string > | getStringValue (const std::string &member_key=std::string("")) const |
KeyRequirement | getImperative () const |
Report whether a keyword has been deemed essential, optional, or bogus in a particular context. This enables the same namelist to take on different profiles in different applications, and to report only that data which is relevant in the program output. | |
KeyRequirement | getImperative (const std::string &sub_key_query) const |
void | setDefaultValue (const std::string &modified_default, int default_idx=0) |
Set the default value for a particular keyword, overriding anything that might have been set beforehand. This can be useful when applying common keyword loading functions, to adapt the namelist elements for a specific program or context. | |
void | setDefaultValue (const std::vector< std::string > &modified_defaults, const std::vector< std::string > &sub_key_specs) |
void | activateBool () |
Activate a boolean value based on the mere presence of a keyword in the namelist. This function will check to verify that the keyword is a boolean. | |
void | activateBool (const std::string &su_key_query) |
void | setIntValue (int value) |
Set an integer value within this namelist element. This function will check to ensure that the element expects an int. | |
void | setIntValue (const std::string &member_key, int value) |
void | setRealValue (double value) |
Set a real value within this namelist element. This function will check to ensure that the element expects a real number. | |
void | setRealValue (const std::string &member_key, double value) |
void | setStringValue (const std::string &value) |
Set a string value within this namelist element. This function will check to ensure that the element expects a string value. | |
void | setStringValue (const std::string &member_key, const std::string &value) |
void | setImperative (const KeyRequirement imperative_in) |
Set the requirement associated with a keyword. | |
void | setImperative (const std::string &sub_key_query, const KeyRequirement imperative_in) |
Friends | |
struct | NamelistEmulator |
One keyword found in a namelist, ready to store the namelist variable moniker, the type, and the value read from the input file.
stormm::namelist::NamelistElement::NamelistElement | ( | const std::string & | keyword_in, |
NamelistType | kind_in, | ||
const std::string & | default_in = std::string(""), | ||
DefaultIsObligatory | obligate = DefaultIsObligatory::NO, | ||
InputRepeats | rep_in = InputRepeats::NO, | ||
const std::string & | help_in = std::string("No description provided") ) |
Constructor for a non-STRUCT NamelistElement.
Overloaded:
keyword_in | The name of the namelist variable |
sub_keys_in | The name of STRUCT members within the namelist variable |
kind_in | The kind of the namelist element (it will be checked to ensure that it is not STRUCT) |
sub_kinds_in | The kinds of STRUCT members (the namelist variable itself is a STRUCT if this input argument is a vector) |
rep_in | Flag to indicate whether the namelist input can repeat for additional values |
help_in | User documentation for the keyword |
sub_help_in | User documentation for sub-keys |
|
default |
With no const members and only Standard Template Library components, the default copy and move constructors, as well as the copy and move assignment operators, are valid.
original | The pre-existing object to copy or move |
other | A pre-existing object to fulfill the right hand side of an assignment statement |
void stormm::namelist::NamelistElement::activateBool | ( | ) |
Activate a boolean value based on the mere presence of a keyword in the namelist. This function will check to verify that the keyword is a boolean.
Overloaded:
void stormm::namelist::NamelistElement::addDefaultValue | ( | const std::string & | next_default | ) |
Include an additional value as a default setting for a particular keyword. This enables a single keyword to have a default series of values. The supplied value will be interpreted according to the type of the element.
next_default | The extra default value to include |
bool stormm::namelist::NamelistElement::getBoolValue | ( | const std::string & | member_key, |
int | index ) const |
Get the boolean value to which a namelist element has been set (this value is set to TRUE if the keyword was found in the namelist or collection of STRUCT sub-keys, FALSE if not).
Overloaded:
member_key | The (optional) name of a STRUCT member to access (an empty string indicates that the keyword is associated with INTEGER, REAL, or STRING data) |
index | The entry to access |
InputStatus stormm::namelist::NamelistElement::getEstablishment | ( | const std::string & | member_key = std::string(""), |
int | repeat_no = 0 ) const |
Report whether a value has been assigned, read from input, to this namelist element.
member_key | Name of the sub-key to search if the namelist element is a STRUCT |
repeat_no | Index number of the repeated keyword application, if applicable. The establishment of a member keyword in the fourth application of a repeatable STRUCT keyword will be found in element 4 * (template_size) + member_idx of the input status array. |
KeyRequirement stormm::namelist::NamelistElement::getImperative | ( | ) | const |
Report whether a keyword has been deemed essential, optional, or bogus in a particular context. This enables the same namelist to take on different profiles in different applications, and to report only that data which is relevant in the program output.
Overloaded:
sub_key_query | Name of the sub-key to search if the namelist element is a STRUCT |
int stormm::namelist::NamelistElement::getIntValue | ( | const std::string & | member_key, |
int | index ) const |
Get the integer value to which a namelist element has been set (this value is read from the namelist input file, i.e. mdin). Descriptions of input parameters follow from getBoolValue(), above.
Overloaded:
NamelistType stormm::namelist::NamelistElement::getKind | ( | ) | const |
Get the kind associated with a namelist element, i.e. nstlim is an INTEGER in Amber &ctrl.
Overloaded:
const std::string & stormm::namelist::NamelistElement::getStringValue | ( | const std::string & | member_key, |
int | index ) const |
Get the string value to which a namelist element has been set (this value is read from the namelist input file, i.e. mdin)
Overloaded:
member_key | The (optional) name of a STRUCT member to access |
index | The entry to access |
void stormm::namelist::NamelistElement::reportNamelistTypeProblem | ( | const std::string & | caller, |
const std::string & | data_type ) const |
Report an error based on an incorrect namelist element data type request. This is an assertion that debugs a program when a developer makes a mistake, not something that an end user should encounter, but it's helpful to have a more detailed description than assert() can provide. This always ends by throwing a runtime error and so is an acceptable way to fill a switch case.
caller | The name of the member function of NamelistElement calling this error |
data_type | The name of the (erroneously) requested data type |
void stormm::namelist::NamelistElement::setDefaultValue | ( | const std::string & | modified_default, |
int | default_idx = 0 ) |
Set the default value for a particular keyword, overriding anything that might have been set beforehand. This can be useful when applying common keyword loading functions, to adapt the namelist elements for a specific program or context.
Overloaded:
modified_default | The new default setting to apply to the keyword |
default_idx | The index of the default to set, in the event that there are already multiple default values |
modified_defaults | The list of modified default values |
sub_key_specs | The list of sub-keys to which each default corresponds |
void stormm::namelist::NamelistElement::setImperative | ( | const KeyRequirement | imperative_in | ) |
Set the requirement associated with a keyword.
Overloaded:
imperative_in | The criticality level of the keyword to set. Is it required, optional, or bogus in some context? |
void stormm::namelist::NamelistElement::setIntValue | ( | int | value | ) |
Set an integer value within this namelist element. This function will check to ensure that the element expects an int.
Overloaded:
member_key | If given, implies that the namelist element is a struct, and triggers a search through its members to find a match and finally place the int. |
value | The value of the keyword or sub-key |
void stormm::namelist::NamelistElement::setPolicy | ( | ExceptionResponse | policy_in | ) |
Set the way that this Namelist element will respond if it encounters bad input. The member variable associated with this function is not passed down as part of the constructor argument list, and would be tedious for the developer to enter over and over, so it is passed down based on the NamelistEmulator's own setting by calling this function.
policy_in | The policy to set |
void stormm::namelist::NamelistElement::setRealValue | ( | double | value | ) |
Set a real value within this namelist element. This function will check to ensure that the element expects a real number.
Overloaded:
member_key | If given, implies that the namelist element is a struct, and triggers a search through its members to find a match and finally place the real number. |
value | The value of the keyword or sub-key |
void stormm::namelist::NamelistElement::setStringValue | ( | const std::string & | value | ) |
Set a string value within this namelist element. This function will check to ensure that the element expects a string value.
Overloaded:
member_key | If given, implies that the namelist element is a struct, and triggers a search through its members to find a match and finally place the string. |
value | The value of the keyword or sub-key |