Registry of capabilities that checks capability requirements. More...
#include <CapabilityRegistry.h>
Classes | |
| struct | CheckOptions |
| Options for check(). More... | |
| struct | CheckResult |
| Storage for the result from check(). More... | |
Public Types | |
| enum | CheckState { CERTAIN_FAIL = 0, POSSIBLE_FAIL = 1, UNKNOWN = 2, POSSIBLE_PASS = 3, CERTAIN_PASS = 4, IGNORE = 5 } |
| Return state for check. More... | |
| using | RegistryType = std::map< std::string, Capability, std::less<> > |
| Type for the registry. More... | |
Public Member Functions | |
| ~CapabilityRegistry ()=default | |
| Capability & | add (const std::string_view name, const Moose::Capability::Value &value, const std::string_view doc) |
| Add a capability. More... | |
| std::size_t | size () const |
| CheckResult | check (std::string requirements, const CapabilityRegistry::CheckOptions &options=CapabilityRegistry::CheckOptions()) const |
| Checks if a set of requirements is satisified by the capabilities. More... | |
| const Capability * | query (std::string capability) const |
| Query a capability, if it exists, otherwise nullptr. More... | |
| Capability * | query (std::string capability) |
| const Capability & | get (const std::string &capability) const |
| Get a capability. More... | |
| Capability & | get (const std::string &capability) |
Static Public Attributes | |
| static const std::set< std::string, std::less<> > | augmented_capability_names |
| Capabilities that are reserved and can only be augmented. More... | |
Protected Attributes | |
| RegistryType | _registry |
| Registry storage. More... | |
Friends | |
| class | ::CapabilitiesTest |
Registry of capabilities that checks capability requirements.
This registry is used both within MOOSE (in framework/src/base/Capabilities.C) and within the python interface (in python/pycapabilities/_pycapabilities.C).
Definition at line 34 of file CapabilityRegistry.h.
| using Moose::internal::CapabilityRegistry::RegistryType = std::map<std::string, Capability, std::less<> > |
Type for the registry.
Definition at line 43 of file CapabilityRegistry.h.
Return state for check.
We use a plain enum because we rely on implicit conversion to int. Capability checks are run in the test harness using the JSON dump exported from the executable using --show-capabilities. This static check does not take dynamic loading into account, as capabilities that would be registered after initializing the dynamically loaded application will not exist with --show-capabilities.
A requested capability that is not registered at all is considered in a "possible" state, as we cannot guarantee that it does or not exist with a dynamic application. If no dynamic application loading is used, the possible states can be considered certain states.
When the test harness Tester specification "dynamic_capabilities" is set to True, it will run the test unless the result of the check is CERTAIN_FAIL. In this case, the runtime check in the executable will terminate if the result is either CERTAIN_FAIL or POSSIBLE_FAIL.
| Enumerator | |
|---|---|
| CERTAIN_FAIL | |
| POSSIBLE_FAIL | |
| UNKNOWN | |
| POSSIBLE_PASS | |
| CERTAIN_PASS | |
| IGNORE | |
Definition at line 61 of file CapabilityRegistry.h.
|
default |
| Capability & Moose::internal::CapabilityRegistry::add | ( | const std::string_view | name, |
| const Moose::Capability::Value & | value, | ||
| const std::string_view | doc | ||
| ) |
Add a capability.
| registry | The registry |
| capability | The name of the capability |
| value | The value of the capability |
| doc | The documentation string |
Definition at line 34 of file CapabilityRegistry.C.
Referenced by Registry::addDataFilePathCapability(), Moose::internal::Capabilities::augment(), AppFactory::registerAppCapability(), and Moose::internal::Capabilities::registerMooseCapabilities().
| CapabilityRegistry::CheckResult Moose::internal::CapabilityRegistry::check | ( | std::string | requirements, |
| const CapabilityRegistry::CheckOptions & | options = CapabilityRegistry::CheckOptions() |
||
| ) | const |
Checks if a set of requirements is satisified by the capabilities.
| requirements | The requirement string |
| options | Options to apply to the check |
This method is exposed to Python within pycapabilities.Capabilities.check in python/pycapabilities/_pycapabilities.C. This external method is used significantly by the TestHarness to check capabilities for individual test specs.
Additionally, this method is used by the MooseApp command line option "--required-capabilities ...".
Requirements can use comparison operators (>,<,>=,<=,=!,=), where the name of the capability must always be on the left hand side. Comparisons can be performed on strings "compiler!=GCC" (which are case insensitive), integer numbers "ad_size>=50", and version numbers "petsc>3.8.0". The state of a boolean valued capability can be tested by just specifying the capability name "chaco". This check can be inverted using the ! operator as "!chaco".
The logic operators & and | can be used to chain multiple checks as "thermochimica & thermochimica>1.0". Parenthesis can be used to build complex logic expressions.
Definition at line 86 of file CapabilityRegistry.C.
| const Capability & Moose::internal::CapabilityRegistry::get | ( | const std::string & | capability | ) | const |
Get a capability.
Will convert the capability name to lowercase.
Definition at line 66 of file CapabilityRegistry.C.
Referenced by MooseApp::setupOptions().
|
inline |
Definition at line 184 of file CapabilityRegistry.h.
| const Capability * Moose::internal::CapabilityRegistry::query | ( | std::string | capability | ) | const |
Query a capability, if it exists, otherwise nullptr.
Will convert the capability name to lowercase.
Definition at line 57 of file CapabilityRegistry.C.
Referenced by check(), and get().
|
inline |
Definition at line 176 of file CapabilityRegistry.h.
|
inline |
Definition at line 135 of file CapabilityRegistry.h.
|
friend |
Definition at line 167 of file CapabilityRegistry.h.
|
protected |
Registry storage.
Definition at line 171 of file CapabilityRegistry.h.
Referenced by add(), check(), Moose::internal::Capabilities::dump(), query(), and size().
|
static |
Capabilities that are reserved and can only be augmented.
Definition at line 38 of file CapabilityRegistry.h.
1.8.14