|
ampsci
High-precision calculations for one- and two-valence atomic systems
|
Singleton registry of all compiled-in modules.
Populated at program startup via static initialisers – one per module .cpp file – and never modified once main() begins.
The "construct on first use" idiom in get() avoids the static-initialisation order fiasco: the Register constructor calls Registry::get(), which forces the singleton to be created before any module tries to register itself. Order of registration across translation units is unspecified, but for this registry that does not matter.
Module authors do not normally need to interact with the Registry directly; they self-register via Register. The ampsci driver uses the Registry via runModule, runModules and list_modules.
#include <Modules.hpp>
Public Member Functions | |
| void | add (std::string name, std::string description, ModuleFn fn) |
| Append a new entry to the registry. | |
| const std::vector< ModuleEntry > & | entries () const |
| All registered modules, in registration order. | |
| const ModuleEntry * | find (const std::string &name) const |
| Look up a module by name. | |
Static Public Member Functions | |
| static Registry & | get () |
| Access the singleton instance. | |
|
inlinestatic |
Access the singleton instance.
|
inline |
Append a new entry to the registry.
Normally called only by the Register constructor.
| name | Module name as used in input files. |
| description | One-line description (shown by ./ampsci -m). |
| fn | Pointer to the module function. |
|
inline |
All registered modules, in registration order.
|
inline |
Look up a module by name.
| name | Module name (case sensitive; same string passed to Register). |
nullptr if no module with that name is registered.