25#include "neml2/base/Registry.h"
26#include "neml2/base/NEML2Object.h"
37std::map<std::string, OptionSet>
41 return reg._expected_options;
49 reg._expected_options.count(name) > 0,
51 " is not a registered object. Did you forget to register it with register_NEML2_object?");
52 return reg._expected_options.at(name);
59 return reg._syntax_type[type];
67 reg._objects.count(name) > 0,
69 " is not a registered object. Did you forget to register it with register_NEML2_object?");
70 return reg._objects.at(name);
74Registry::add_inner(
const std::string & name,
75 const std::string & type,
80 neml_assert(
reg._expected_options.count(name) == 0 &&
reg._objects.count(name) == 0,
81 "Duplicate registration found. Object named ",
83 " is being registered multiple times.");
85 reg._expected_options[name] = options;
87 reg._syntax_type[name] = type;
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
static std::map< std::string, OptionSet > expected_options()
Return the expected options of all registered classs.
Definition Registry.cxx:38
static Registry & get()
Get the global Registry singleton.
Definition Registry.cxx:31
static BuildPtr builder(const std::string &name)
Return the build method pointer of a specific registered class.
Definition Registry.cxx:63
static std::string syntax_type(const std::string &type)
Return the syntax type (what appears in the input file) given a registered object's type.
Definition Registry.cxx:56
Definition CrossRef.cxx:32
std::shared_ptr< NEML2Object >(*)(const OptionSet &options) BuildPtr
Definition Registry.h:42
void neml_assert(bool assertion, Args &&... args)
Definition error.h:73