My Project
Loading...
Searching...
No Matches
ScriptRegistry Class Reference

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 ScriptRegistryInstance ()
 Returns the singleton instance of the ScriptRegistry.

Detailed Description

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.

Member Typedef Documentation

◆ ScriptFactory

using ScriptRegistry::ScriptFactory = std::function<std::unique_ptr<UserScript>()>

Type alias for a factory function that returns a unique_ptr to a UserScript.

Member Function Documentation

◆ CreateAll()

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.

Returns
Vector of unique_ptr<UserScript> containing all instantiated scripts

◆ Instance()

ScriptRegistry & ScriptRegistry::Instance ( )
static

Returns the singleton instance of the ScriptRegistry.

Returns
Reference to the singleton ScriptRegistry

◆ Register()

void ScriptRegistry::Register ( ScriptFactory factory)

Registers a script factory function.

The factory function should create and return a new instance of a UserScript.

Parameters
factoryA function that creates a new UserScript

The documentation for this class was generated from the following file: