Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Static Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
Olympe::ConditionEvaluator Class Reference

Stateless evaluator for structured Condition expressions. More...

#include <ConditionEvaluator.h>

Static Public Member Functions

static bool EvaluateAll (const std::vector< Condition > &conditions, const LocalBlackboard &localBB, const std::unordered_map< std::string, TaskValue > &dataPinCache, int32_t nodeID)
 Evaluates all conditions (implicit AND) on a Branch/While node.
 
static bool EvaluateCondition (const Condition &cond, const LocalBlackboard &localBB, const std::unordered_map< std::string, TaskValue > &dataPinCache, int32_t nodeID)
 Evaluates a single Condition.
 
static bool GetConditionValue (const std::string &mode, const std::string &pin, const std::string &variable, const TaskValue &constValue, const LocalBlackboard &localBB, const std::unordered_map< std::string, TaskValue > &dataPinCache, int32_t nodeID, TaskValue &outValue)
 Resolves the TaskValue for one side of a condition.
 
static bool CompareValues (const TaskValue &left, const TaskValue &right, const std::string &op, int32_t nodeID)
 Compares two TaskValues using the given operator.
 

Private Member Functions

 ConditionEvaluator ()=delete
 

Static Private Member Functions

static bool ParsePinRef (const std::string &pinRef, int32_t &outNodeID, std::string &outPinName)
 Parses "Node#42.Out" -> nodeID=42, pinName="Out".
 

Detailed Description

Stateless evaluator for structured Condition expressions.

All methods are static. Call EvaluateAll() with the full conditions list from a TaskNodeDefinition to compute the implicit-AND result.

Pin values are looked up in the DataPinCache map (keyed as "nodeID:pinName"). The pin field format is "Node#<id>.<pinName>", e.g. "Node#42.Out".

Definition at line 45 of file ConditionEvaluator.h.

Constructor & Destructor Documentation

◆ ConditionEvaluator()

Olympe::ConditionEvaluator::ConditionEvaluator ( )
privatedelete

Member Function Documentation

◆ CompareValues()

bool Olympe::ConditionEvaluator::CompareValues ( const TaskValue left,
const TaskValue right,
const std::string &  op,
int32_t  nodeID 
)
static

Compares two TaskValues using the given operator.

Supported operators: "==", "!=", "<", ">", "<=", ">=". If types differ, attempts Int->Float promotion. On unresolvable mismatch logs WARNING and returns false.

Parameters
leftLeft-hand value.
rightRight-hand value.
opOperator string.
nodeIDNode ID for logging.
Returns
Result of the comparison, or false on error.

Definition at line 170 of file ConditionEvaluator.cpp.

References Olympe::TaskValue::AsBool(), Olympe::TaskValue::AsFloat(), Olympe::TaskValue::AsInt(), Olympe::TaskValue::AsString(), Olympe::TaskValue::AsVector(), Olympe::Bool, Olympe::Float, GetComponentTypeID_Static(), Olympe::TaskValue::GetType(), Olympe::Int, Olympe::String, SYSTEM_LOG, and Olympe::Vector.

Referenced by EvaluateCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EvaluateAll()

bool Olympe::ConditionEvaluator::EvaluateAll ( const std::vector< Condition > &  conditions,
const LocalBlackboard localBB,
const std::unordered_map< std::string, TaskValue > &  dataPinCache,
int32_t  nodeID 
)
static

Evaluates all conditions (implicit AND) on a Branch/While node.

Parameters
conditionsThe conditions list from the node definition.
localBBThe entity's local blackboard (for Variable mode).
dataPinCacheFrame-local data pin cache (for Pin mode).
nodeIDNode ID used in log messages.
Returns
true if all conditions evaluate to true (or list is empty).

Definition at line 24 of file ConditionEvaluator.cpp.

References EvaluateCondition(), and GetComponentTypeID_Static().

Referenced by Olympe::VSGraphExecutor::HandleBranch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EvaluateCondition()

bool Olympe::ConditionEvaluator::EvaluateCondition ( const Condition cond,
const LocalBlackboard localBB,
const std::unordered_map< std::string, TaskValue > &  dataPinCache,
int32_t  nodeID 
)
static

Evaluates a single Condition.

Parameters
condThe condition to evaluate.
localBBThe entity's local blackboard.
dataPinCacheFrame-local data pin cache.
nodeIDNode ID for log context.
Returns
true if the condition holds; false on any error or when false.

Definition at line 46 of file ConditionEvaluator.cpp.

References CompareValues(), GetComponentTypeID_Static(), GetConditionValue(), and SYSTEM_LOG.

Referenced by EvaluateAll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConditionValue()

bool Olympe::ConditionEvaluator::GetConditionValue ( const std::string &  mode,
const std::string &  pin,
const std::string &  variable,
const TaskValue constValue,
const LocalBlackboard localBB,
const std::unordered_map< std::string, TaskValue > &  dataPinCache,
int32_t  nodeID,
TaskValue outValue 
)
static

Resolves the TaskValue for one side of a condition.

Parameters
mode"Pin", "Variable", or "Const".
pinPin reference string (mode == "Pin").
variableVariable name (mode == "Variable").
constValueLiteral value (mode == "Const").
localBBLocal blackboard.
dataPinCacheData pin cache.
nodeIDNode ID for logging.
outValueOutput value (only valid when return is true).
Returns
true if the value was successfully resolved.

Definition at line 81 of file ConditionEvaluator.cpp.

References GetComponentTypeID_Static(), ParsePinRef(), and SYSTEM_LOG.

Referenced by EvaluateCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ParsePinRef()

bool Olympe::ConditionEvaluator::ParsePinRef ( const std::string &  pinRef,
int32_t outNodeID,
std::string &  outPinName 
)
staticprivate

Parses "Node#42.Out" -> nodeID=42, pinName="Out".

Returns false if the format is not recognised.

Definition at line 265 of file ConditionEvaluator.cpp.

References GetComponentTypeID_Static().

Referenced by GetConditionValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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