14 #include "nlohmann/json.h" 27 if (!capability_registry)
29 return *capability_registry;
35 const std::string & doc)
38 if (std::holds_alternative<std::string>(
value))
43 it_pair->second.first ==
value)
48 "' was already registered with a different value. ('",
58 add(capability, std::string(
value), std::string(doc));
67 const auto &
value = value_doc.first;
68 const auto & doc = value_doc.second;
69 if (std::holds_alternative<bool>(
value))
70 root[capability] = {std::get<bool>(
value), doc};
71 else if (std::holds_alternative<int>(
value))
72 root[capability] = {std::get<int>(
value), doc};
73 else if (std::holds_alternative<std::string>(
value))
74 root[capability] = {std::get<std::string>(
value), doc};
76 mooseError(
"Unknown type in capabilities registry");
This singleton class holds a registry for capabilities supported by the current app.
std::string toLower(const std::string &name)
Convert supplied string to lower case.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
CapabilityUtils::Result check(const std::string &requested_capabilities) const
check if the given required capabilities are fulfilled, returns a bool, a reason, and a verbose docum...
std::tuple< CheckState, std::string, std::string > Result
Result from a capability check: the state, the reason, and the documentation.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::string dump() const
create a JSON dump of the capabilities registry
std::string stringify(const T &t)
conversion to string
static Capabilities & getCapabilityRegistry()
std::variant< bool, int, std::string > Type
A capability can have a bool, int, or string value.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
void add(const std::string &capability, CapabilityUtils::Type value, const std::string &doc)
register a new capability
Result check(std::string requirements, const Registry &capabilities)
Checks if a set of requirements is satisified by the given capability registry.
std::map< std::string, std::pair< CapabilityUtils::Type, std::string > > _capability_registry
Capability registry.