Registry that allows for the typeless setting of a parameter value from a hit field.
More...
#include <ParameterRegistry.h>
Registry that allows for the typeless setting of a parameter value from a hit field.
Definition at line 43 of file ParameterRegistry.h.
◆ ParameterRegistry()
Moose::ParameterRegistry::ParameterRegistry |
( |
| ) |
|
|
inlineprivate |
Constructor; private so that it can only be created with the singleton.
Definition at line 66 of file ParameterRegistry.h.
Referenced by get().
◆ add()
template<class T , class F >
char Moose::ParameterRegistry::add |
( |
F && |
f | ) |
|
Add a parameter.
Definition at line 84 of file ParameterRegistry.h.
86 static_assert(std::is_invocable_r_v<void, F &, T &, const hit::Field &>,
87 "Setter function must be callable with (T &, const hit::Field &) and return void");
93 const hit::Field & field) ->
void 96 mooseAssert(cast_param_value,
"Cast failed");
97 f(cast_param_value->set(), field);
100 const std::type_index key(
typeid(T));
101 const auto it_inserted_pair =
_registry.emplace(key, std::move(setter));
103 if (!it_inserted_pair.second)
104 mooseError(
"ParameterRegistry: Parameter with type '",
105 MooseUtils::prettyCppType<T>(),
106 "' is already registered");
std::unordered_map< std::type_index, std::function< void(libMesh::Parameters::Value &value, const hit::Field &)> > _registry
Registration map of type -> function to fill each type.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
◆ FRIEND_TEST() [1/5]
Moose::ParameterRegistry::FRIEND_TEST |
( |
::ParameterRegistryTest |
, |
|
|
add |
|
|
) |
| |
|
private |
◆ FRIEND_TEST() [2/5]
Moose::ParameterRegistry::FRIEND_TEST |
( |
::ParameterRegistryTest |
, |
|
|
addExists |
|
|
) |
| |
|
private |
◆ FRIEND_TEST() [3/5]
Moose::ParameterRegistry::FRIEND_TEST |
( |
::ParameterRegistryTest |
, |
|
|
set |
|
|
) |
| |
|
private |
◆ FRIEND_TEST() [4/5]
Moose::ParameterRegistry::FRIEND_TEST |
( |
::ParameterRegistryTest |
, |
|
|
setNotRegistered |
|
|
) |
| |
|
private |
◆ FRIEND_TEST() [5/5]
Moose::ParameterRegistry::FRIEND_TEST |
( |
::ParameterRegistryTest |
, |
|
|
setCatchMooseError |
|
|
) |
| |
|
private |
◆ get()
◆ set()
Sets a parameter value given a hit field.
Definition at line 26 of file ParameterRegistry.C.
Referenced by Moose::Builder::extractParams().
28 const std::type_index key(
value.type_info());
31 mooseError(
"ParameterRegistry::set(): Parameter type '",
33 "' is not registered");
39 it->second(value, field);
std::unordered_map< std::type_index, std::function< void(libMesh::Parameters::Value &value, const hit::Field &)> > _registry
Registration map of type -> function to fill each type.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Scoped helper for setting Moose::_throw_on_error during this scope.
std::string prettyCppType(const std::string &cpp_type)
◆ _registry
The documentation for this class was generated from the following files: