15 #include "libmesh/parameters.h" 19 #ifdef MOOSE_UNIT_TEST 20 #include "gtest/gtest.h" 51 template <
class T,
class F>
65 #ifdef MOOSE_UNIT_TEST 69 FRIEND_TEST(::ParameterRegistryTest, setNotRegistered);
70 FRIEND_TEST(::ParameterRegistryTest, setCatchMooseError);
74 std::map<std::string, std::function<void(libMesh::Parameters::Value & value, const hit::Field &)>>
78 template <
class T,
class F>
82 static_assert(std::is_invocable_r_v<void, F &, T &, const hit::Field &>,
83 "Setter function must be callable with (T &, const hit::Field &) and return void");
89 const hit::Field & field) ->
void 92 mooseAssert(cast_param_value,
"Cast failed");
93 f(cast_param_value->set(), field);
97 const auto it_inserted_pair =
_registry.emplace(key, std::move(setter));
99 if (!it_inserted_pair.second)
100 mooseError(
"ParameterRegistry: Parameter with type '", key,
"' is already registered");
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Registry that allows for the typeless setting of a parameter value from a hit field.
ParameterRegistry()
Constructor; private so that it can only be created with the singleton.
class GTEST_TEST_CLASS_NAME_(ParameterRegistryTest, add)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::string demangle(const char *name)
FRIEND_TEST(::ParameterRegistryTest, add)
char add(F &&f)
Add a parameter.
std::map< std::string, std::function< void(libMesh::Parameters::Value &value, const hit::Field &)> > _registry
Registration map of type -> function to fill each type.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...