Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
AtomicTaskRegistry.h File Reference

Singleton registry for atomic task factories. More...

#include <string>
#include <unordered_map>
#include <functional>
#include <memory>
#include "IAtomicTask.h"
+ Include dependency graph for AtomicTaskRegistry.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Olympe::AtomicTaskRegistry
 Singleton registry mapping task IDs to factory functions. More...
 

Namespaces

namespace  Olympe
 < Provides AssetID and INVALID_ASSET_ID
 

Macros

#define REGISTER_ATOMIC_TASK(ClassName, Id)
 Registers a factory for ClassName under Id at static init time.
 

Detailed Description

Singleton registry for atomic task factories.

Author
Olympe Engine
Date
2026-02-22

AtomicTaskRegistry stores factory functions keyed by a string task ID. Call Register() to associate a factory with an ID, and Create() to instantiate a task by ID.

The REGISTER_ATOMIC_TASK(ClassName, Id) macro registers a factory at static initialization time so that every translation unit that includes the concrete task's .cpp file automatically populates the registry.

C++14 compliant - no C++17/20 features.

Definition in file AtomicTaskRegistry.h.

Macro Definition Documentation

◆ REGISTER_ATOMIC_TASK

#define REGISTER_ATOMIC_TASK (   ClassName,
  Id 
)
Value:
namespace { \
struct ClassName##_Registrar { \
::Olympe::AtomicTaskRegistry::Get().Register( \
Id, \
[]() -> std::unique_ptr<::Olympe::IAtomicTask> { \
return std::unique_ptr<::Olympe::IAtomicTask>( \
new ClassName()); \
}); \
} \
}; \
}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56

Registers a factory for ClassName under Id at static init time.

Place this macro in the .cpp file of your concrete task class (outside any namespace or function):

REGISTER_ATOMIC_TASK(Task_LogMessage, "Task_LogMessage")
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.

The macro creates a file-scope object whose constructor calls AtomicTaskRegistry::Get().Register(), ensuring registration happens before main() is entered.

Definition at line 119 of file AtomicTaskRegistry.h.