Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Task_LogMessage.cpp
Go to the documentation of this file.
1/**
2 * @file Task_LogMessage.cpp
3 * @brief Example atomic task that logs a message parameter.
4 * @author Olympe Engine
5 * @date 2026-02-22
6 *
7 * @details
8 * Task_LogMessage reads the "message" string parameter from the parameter map
9 * and writes it to the system log. Returns TaskStatus::Success unconditionally.
10 *
11 * Parameter map:
12 * "message" (String) - the text to log. Defaults to "(no message)" if absent.
13 *
14 * C++14 compliant - no C++17/20 features.
15 */
16
17#include "../AtomicTaskRegistry.h"
18#include "../../system/system_utils.h"
19
20namespace Olympe {
21
22/**
23 * @class Task_LogMessage
24 * @brief Atomic task that logs the value of the "message" parameter.
25 */
27public:
28
30 {
31 std::string message = "(no message)";
32
33 auto it = params.find("message");
34 if (it != params.end() && it->second.GetType() == VariableType::String)
35 {
36 message = it->second.AsString();
37 }
38
39 SYSTEM_LOG << "[Task_LogMessage] " << message << "\n";
40
42 }
43
44 void Abort() override
45 {
46 // Task_LogMessage is instantaneous (always returns Success on first
47 // Execute() call), so there is no in-progress state to clean up.
48 }
49};
50
51REGISTER_ATOMIC_TASK(Task_LogMessage, "Task_LogMessage")
52
53} // namespace Olympe
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Abstract interface for a single atomic unit of work.
Definition IAtomicTask.h:63
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition IAtomicTask.h:67
Atomic task that logs the value of the "message" parameter.
void Abort() override
Aborts the task, releasing any in-progress state.
TaskStatus Execute(const ParameterMap &params) override
Executes the atomic task for one frame.
< Provides AssetID and INVALID_ASSET_ID
@ String
std::string
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition IAtomicTask.h:38
@ Success
Task completed successfully.
#define SYSTEM_LOG