|
My Project
|
Singleton registry that manages user script factories and can instantiate scripts on demand. More...
#include <ScriptRegister.hpp>
Public Types | |
| using | ScriptFactory = std::function<std::unique_ptr<UserScript>()> |
| Type alias for a factory function that returns a unique_ptr to a UserScript. | |
Public Member Functions | |
| void | Register (ScriptFactory factory) |
| Registers a script factory function. | |
| std::vector< std::unique_ptr< UserScript > > | CreateAll () |
| Creates instances of all registered scripts. | |
Static Public Member Functions | |
| static ScriptRegistry & | Instance () |
| Returns the singleton instance of the ScriptRegistry. | |
Singleton registry that manages user script factories and can instantiate scripts on demand.
This registry allows scripts to register a factory function that creates instances of UserScript. It is used by the ScriptManager to initialize and manage all user scripts.
| using ScriptRegistry::ScriptFactory = std::function<std::unique_ptr<UserScript>()> |
Type alias for a factory function that returns a unique_ptr to a UserScript.
| std::vector< std::unique_ptr< UserScript > > ScriptRegistry::CreateAll | ( | ) |
Creates instances of all registered scripts.
Calls each registered factory function and collects the resulting UserScript instances into a vector, which is returned to the caller.
|
static |
Returns the singleton instance of the ScriptRegistry.
| void ScriptRegistry::Register | ( | ScriptFactory | factory | ) |
Registers a script factory function.
The factory function should create and return a new instance of a UserScript.
| factory | A function that creates a new UserScript |