|
commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
|
A program-wide registry mapping an origin kind string to a factory.
More...
#include <origin.hpp>
Public Types | |
| using | Factory = OriginPtr(*)() |
| Produces a fresh, default-constructed origin of one kind. | |
Public Member Functions | |
| bool | register_kind (const std::string_view kind, Factory factory) |
Register factory under kind. | |
| OriginPtr | create (const std::string_view kind) const |
Create a fresh origin for kind, or nullptr if the kind is unknown. | |
| bool | contains (const std::string_view kind) const |
Whether kind has a registered factory. | |
A program-wide registry mapping an origin kind string to a factory.
A Meyers singleton, like GlobalFlagRegistry, so the map is constructed before any inline registrar runs. Used by the JSON from_json path to turn a kind discriminator back into the right concrete origin.
|
inline |
Register factory under kind.
Returns false if the kind was already registered (the first registration wins).