14#include "../../AtomicTaskRegistry.h"
15#include "../../../system/system_utils.h"
44 SYSTEM_LOG <<
"[Task_Compare] Missing or invalid 'Operator' parameter\n";
47 op =
it->second.AsString();
56 SYSTEM_LOG <<
"[Task_Compare] Missing 'LHS' or 'RHS' parameter\n";
63 if (
lhs.GetType() !=
rhs.GetType())
65 SYSTEM_LOG <<
"[Task_Compare] Type mismatch between LHS and RHS\n";
71 switch (
lhs.GetType())
77 if (op ==
"==") result = (
l ==
r);
78 else if (op ==
"!=") result = (
l !=
r);
79 else if (op ==
"<") result = (
l <
r);
80 else if (op ==
"<=") result = (
l <=
r);
81 else if (op ==
">") result = (
l >
r);
82 else if (op ==
">=") result = (
l >=
r);
85 SYSTEM_LOG <<
"[Task_Compare] Unknown operator '" << op <<
"'\n";
92 float l =
lhs.AsFloat();
93 float r =
rhs.AsFloat();
97 if (op ==
"==") result = (
l ==
r);
98 else if (op ==
"!=") result = (
l !=
r);
99 else if (op ==
"<") result = (
l <
r);
100 else if (op ==
"<=") result = (
l <=
r);
101 else if (op ==
">") result = (
l >
r);
102 else if (op ==
">=") result = (
l >=
r);
105 SYSTEM_LOG <<
"[Task_Compare] Unknown operator '" << op <<
"'\n";
112 const std::string&
l =
lhs.AsString();
113 const std::string&
r =
rhs.AsString();
114 if (op ==
"==") result = (
l ==
r);
115 else if (op ==
"!=") result = (
l !=
r);
116 else if (op ==
"<") result = (
l <
r);
117 else if (op ==
"<=") result = (
l <=
r);
118 else if (op ==
">") result = (
l >
r);
119 else if (op ==
">=") result = (
l >=
r);
122 SYSTEM_LOG <<
"[Task_Compare] Unknown operator '" << op <<
"'\n";
128 SYSTEM_LOG <<
"[Task_Compare] Unsupported type for comparison\n";
132 SYSTEM_LOG <<
"[Task_Compare] Comparison result: " << (result ?
"true" :
"false") <<
"\n";
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
ComponentTypeID GetComponentTypeID_Static()
Atomic task that compares two values and returns Success or Failure.
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
C++14-compliant type-safe value container for task parameters.
int AsInt() const
Returns the int value.
Atomic task that returns Success if a comparison holds, Failure otherwise.
TaskStatus Execute(const ParameterMap ¶ms) override
Executes the atomic task for one frame.
void Abort() override
Aborts the task, releasing any in-progress state.
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap ¶ms) override
Executes the atomic task for one frame with full runtime context.
< Provides AssetID and INVALID_ASSET_ID
@ Int
32-bit signed integer
@ Float
Single-precision float.
TaskStatus
Result code returned by IAtomicTask::Execute().
@ Success
Task completed successfully.
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().