SpECTRE
v2024.12.16
|
Helpers for derived class registration. More...
Classes | |
struct | Registrar |
A template for defining a registrar. More... | |
Helpers for derived class registration.
SpECTRE's factory mechanism requires that the base class contain a list of all derived classes (in the special nested type alias creatable_classes
). This can be problematic when the desired list of derived classes can vary with use of the base class. These helpers provide a method to simplify handling these compile-time registrations.
Each optional derived class defines a registrar helper and both the base class and derived classes are templated on the list of registrars. The typical structure of these classes is:
A concrete base class type with a specific set of derived classes is constructed like
It is frequently useful to default the registrar list in a derived class to the registrar for that class. This ensures that any methods in the base class using the registrar list (such as those using call_with_dynamic_type()
) work as expected on an explicitly constructed derived class with the list omitted.