Class CodeRegistry
Defined in File CodeRegistry.hpp
Class Documentation
-
class CodeRegistry
Registry for client object factories.
Public Functions
-
template<typename T>
void RegisterFactory(const std::string &id, std::function<T*()> factory, std::type_index type) = delete Register a factory for a type of code object.
- Template Parameters:
Code – object base type
- Parameters:
id – The ID of the object factory
factory – A factory function to make the object
type – The type of the object that will be returned from the factory
- Throws:
ExistingValueException – If another factory of the same base type already has the provided ID
Create an object instance using a registered factory.
- Template Parameters:
Code – object base type
- Parameters:
id – The ID of the factory to use
- Throws:
NonexistentValueException – If no factory has been registered with the provided ID for the provided base type
- Returns:
A pair containing the instantiated object and its actual type
Public Static Functions
-
static CodeRegistry &Get()
Get the instance and create one if there isn’t one.
- Returns:
The instance
-
template<typename T>