![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Singleton registry mapping task IDs to factory functions. More...
#include <AtomicTaskRegistry.h>
Public Types | |
| using | FactoryFn = std::function< std::unique_ptr< IAtomicTask >()> |
| Factory function type: returns a heap-allocated IAtomicTask. | |
Public Member Functions | |
| void | Register (const std::string &id, FactoryFn factory) |
| Registers a factory function under the given task ID. | |
| std::unique_ptr< IAtomicTask > | Create (const std::string &id) const |
Creates a new instance of the task identified by id. | |
| bool | IsRegistered (const std::string &id) const |
Returns true if a factory is registered for id. | |
| std::vector< std::string > | GetAllTaskIDs () const |
| Returns a vector of all registered task IDs. | |
Static Public Member Functions | |
| static AtomicTaskRegistry & | Get () |
| Returns the singleton instance. | |
Private Member Functions | |
| AtomicTaskRegistry ()=default | |
Private Attributes | |
| std::unordered_map< std::string, FactoryFn > | m_factories |
Singleton registry mapping task IDs to factory functions.
Usage:
Definition at line 46 of file AtomicTaskRegistry.h.
| using Olympe::AtomicTaskRegistry::FactoryFn = std::function<std::unique_ptr<IAtomicTask>()> |
Factory function type: returns a heap-allocated IAtomicTask.
Definition at line 50 of file AtomicTaskRegistry.h.
|
privatedefault |
| std::unique_ptr< IAtomicTask > Olympe::AtomicTaskRegistry::Create | ( | const std::string & | id | ) | const |
Creates a new instance of the task identified by id.
| id | Task type identifier (as registered via Register()). |
id is unknown. Definition at line 39 of file AtomicTaskRegistry.cpp.
References GetComponentTypeID_Static(), m_factories, and SYSTEM_LOG.
Referenced by Olympe::TaskSystem::ExecuteAtomicTask(), and Olympe::VSGraphExecutor::HandleAtomicTask().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns the singleton instance.
Definition at line 20 of file AtomicTaskRegistry.cpp.
Referenced by Olympe::TaskSystem::ExecuteAtomicTask(), Olympe::VSGraphExecutor::HandleAtomicTask(), and Olympe::NodeGraphPanel::RenderContextMenu().
Here is the caller graph for this function:| std::vector< std::string > Olympe::AtomicTaskRegistry::GetAllTaskIDs | ( | ) | const |
Returns a vector of all registered task IDs.
The order of IDs in the returned vector is unspecified. Useful for editor enumeration (e.g. context menus, palette panels).
Definition at line 101 of file AtomicTaskRegistry.cpp.
References GetComponentTypeID_Static(), and m_factories.
Referenced by Olympe::NodeGraphPanel::RenderContextMenu().
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if a factory is registered for id.
| id | Task type identifier. |
Definition at line 92 of file AtomicTaskRegistry.cpp.
References m_factories.
Registers a factory function under the given task ID.
If a factory is already registered for id, it is replaced.
| id | Unique string identifier for the task type. |
| factory | Callable that produces a new IAtomicTask instance. |
Definition at line 30 of file AtomicTaskRegistry.cpp.
References GetComponentTypeID_Static(), and m_factories.
Here is the call graph for this function:
|
private |
Definition at line 95 of file AtomicTaskRegistry.h.
Referenced by Create(), GetAllTaskIDs(), IsRegistered(), and Register().