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

Simulates blueprint graph execution for validation purposes. More...

#include <GraphExecutionSimulator.h>

Public Member Functions

 GraphExecutionSimulator ()
 
 ~GraphExecutionSimulator ()
 
std::vector< ValidationErrorSimulateExecution (const TaskGraphTemplate &tmpl, const SimulationOptions &options, GraphExecutionTracer &outTracer)
 Simulates execution of a graph template.
 
bool ValidateAllBranches (const TaskGraphTemplate &tmpl, std::vector< ValidationError > &outErrors)
 Validates all branch nodes in a graph.
 
bool ValidateDataConnections (const TaskGraphTemplate &tmpl, std::vector< ValidationError > &outErrors)
 Validates all data connections in a graph.
 
std::vector< int32_tFindUnreachableNodes (const TaskGraphTemplate &tmpl, std::vector< ValidationError > &outErrors)
 Checks for unreachable nodes.
 
bool DetectPotentialInfiniteLoops (const TaskGraphTemplate &tmpl, std::vector< ValidationError > &outErrors)
 Checks for potential infinite loops or cycles.
 

Private Member Functions

int32_t SimulateStep (const TaskGraphTemplate &tmpl, int32_t currentNodeId, LocalBlackboard &blackboard, const SimulationOptions &options, GraphExecutionTracer &tracer)
 
int32_t HandleBranchSimulation (const TaskGraphTemplate &tmpl, int32_t nodeId, LocalBlackboard &blackboard, GraphExecutionTracer &tracer)
 Simulates a Branch node execution.
 
int32_t HandleSwitchSimulation (const TaskGraphTemplate &tmpl, int32_t nodeId, LocalBlackboard &blackboard, GraphExecutionTracer &tracer)
 Simulates a Switch node execution.
 
int32_t HandleSequenceSimulation (const TaskGraphTemplate &tmpl, int32_t nodeId, LocalBlackboard &blackboard, GraphExecutionTracer &tracer)
 Simulates a Sequence node execution.
 
int32_t HandleWhileSimulation (const TaskGraphTemplate &tmpl, int32_t nodeId, LocalBlackboard &blackboard, GraphExecutionTracer &tracer)
 Simulates a While loop execution.
 
int32_t GetNextNodeId (const TaskGraphTemplate &tmpl, int32_t nodeId, const std::string &pinName)
 Gets the next node ID from an execution link.
 
bool ValidateConditionExpression (int32_t nodeId, const std::string &expression)
 Validates a condition expression.
 
void TraceDataPinEvaluation (int32_t nodeId, const TaskGraphTemplate &tmpl, GraphExecutionTracer &tracer, int32_t depth=0)
 Recursively traces data pin evaluation for pure data nodes.
 
void TraceDataConnection (int32_t sourceNodeId, const std::string &sourcePinName, int32_t targetNodeId, const std::string &targetPinName, const TaskGraphTemplate &tmpl, GraphExecutionTracer &tracer, int32_t depth)
 Traces evaluation of a single data connection.
 
void BuildNodeReachabilityMap (const TaskGraphTemplate &tmpl, std::map< int32_t, bool > &reachable)
 
void MarkReachableNodes (const TaskGraphTemplate &tmpl, int32_t nodeId, std::map< int32_t, bool > &reachable)
 

Private Attributes

std::map< int32_t, int32_tm_visitCount
 Track visits per node to detect loops.
 
std::vector< int32_tm_pathStack
 Current execution path.
 
std::set< int32_tm_tracedDataNodes
 Track data nodes already traced to prevent infinite recursion.
 

Detailed Description

Simulates blueprint graph execution for validation purposes.

Simulates graph execution to detect:

The simulator does NOT execute actual AtomicTasks or modify runtime state.

Definition at line 61 of file GraphExecutionSimulator.h.

Constructor & Destructor Documentation

◆ GraphExecutionSimulator()

Olympe::GraphExecutionSimulator::GraphExecutionSimulator ( )

Definition at line 17 of file GraphExecutionSimulator.cpp.

◆ ~GraphExecutionSimulator()

Olympe::GraphExecutionSimulator::~GraphExecutionSimulator ( )

Definition at line 21 of file GraphExecutionSimulator.cpp.

Member Function Documentation

◆ BuildNodeReachabilityMap()

void Olympe::GraphExecutionSimulator::BuildNodeReachabilityMap ( const TaskGraphTemplate tmpl,
std::map< int32_t, bool > &  reachable 
)
private

Definition at line 470 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), and MarkReachableNodes().

+ Here is the call graph for this function:

◆ DetectPotentialInfiniteLoops()

bool Olympe::GraphExecutionSimulator::DetectPotentialInfiniteLoops ( const TaskGraphTemplate tmpl,
std::vector< ValidationError > &  outErrors 
)

Checks for potential infinite loops or cycles.

Parameters
tmplThe TaskGraphTemplate to check.
outErrors[out] Vector to append validation errors to.
Returns
true if potential infinite loops were found.

Definition at line 435 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), GetNextNodeId(), Olympe::NODE_INDEX_NONE, Olympe::Warning, and Olympe::While.

+ Here is the call graph for this function:

◆ FindUnreachableNodes()

std::vector< int32_t > Olympe::GraphExecutionSimulator::FindUnreachableNodes ( const TaskGraphTemplate tmpl,
std::vector< ValidationError > &  outErrors 
)

Checks for unreachable nodes.

Parameters
tmplThe TaskGraphTemplate to check.
outErrors[out] Vector to append validation errors to.
Returns
Vector of unreachable node IDs.

Definition at line 381 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), MarkReachableNodes(), and Olympe::Warning.

Referenced by SimulateExecution().

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

◆ GetNextNodeId()

int32_t Olympe::GraphExecutionSimulator::GetNextNodeId ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
const std::string &  pinName 
)
private

Gets the next node ID from an execution link.

Parameters
tmplThe template.
nodeIdSource node ID.
pinNameExecution output pin name.
Returns
ID of target node, or NODE_INDEX_NONE.

Definition at line 305 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), and Olympe::NODE_INDEX_NONE.

Referenced by DetectPotentialInfiniteLoops(), HandleBranchSimulation(), HandleSequenceSimulation(), HandleSwitchSimulation(), HandleWhileSimulation(), SimulateExecution(), and ValidateAllBranches().

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

◆ HandleBranchSimulation()

int32_t Olympe::GraphExecutionSimulator::HandleBranchSimulation ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
LocalBlackboard blackboard,
GraphExecutionTracer tracer 
)
private

Simulates a Branch node execution.

Returns
ID of the node to execute next, or NODE_INDEX_NONE.

Definition at line 234 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), GetNextNodeId(), and Olympe::NODE_INDEX_NONE.

Referenced by SimulateExecution().

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

◆ HandleSequenceSimulation()

int32_t Olympe::GraphExecutionSimulator::HandleSequenceSimulation ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
LocalBlackboard blackboard,
GraphExecutionTracer tracer 
)
private

Simulates a Sequence node execution.

Definition at line 277 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), GetNextNodeId(), and Olympe::NODE_INDEX_NONE.

Referenced by SimulateExecution().

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

◆ HandleSwitchSimulation()

int32_t Olympe::GraphExecutionSimulator::HandleSwitchSimulation ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
LocalBlackboard blackboard,
GraphExecutionTracer tracer 
)
private

Simulates a Switch node execution.

Definition at line 262 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), GetNextNodeId(), and Olympe::NODE_INDEX_NONE.

Referenced by SimulateExecution().

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

◆ HandleWhileSimulation()

int32_t Olympe::GraphExecutionSimulator::HandleWhileSimulation ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
LocalBlackboard blackboard,
GraphExecutionTracer tracer 
)
private

Simulates a While loop execution.

Definition at line 290 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), GetNextNodeId(), and Olympe::NODE_INDEX_NONE.

Referenced by SimulateExecution().

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

◆ MarkReachableNodes()

void Olympe::GraphExecutionSimulator::MarkReachableNodes ( const TaskGraphTemplate tmpl,
int32_t  nodeId,
std::map< int32_t, bool > &  reachable 
)
private

Definition at line 416 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), and MarkReachableNodes().

Referenced by BuildNodeReachabilityMap(), FindUnreachableNodes(), and MarkReachableNodes().

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

◆ SimulateExecution()

std::vector< ValidationError > Olympe::GraphExecutionSimulator::SimulateExecution ( const TaskGraphTemplate tmpl,
const SimulationOptions options,
GraphExecutionTracer outTracer 
)

Simulates execution of a graph template.

Parameters
tmplThe TaskGraphTemplate to simulate.
optionsSimulation configuration options.
outTracer[out] The execution tracer containing results.
Returns
Vector of validation errors found during simulation.

Definition at line 25 of file GraphExecutionSimulator.cpp.

References Olympe::AtomicTask, Olympe::Branch, Olympe::Critical, Olympe::Delay, Olympe::DoOnce, Olympe::EntryPoint, Olympe::Error, FindUnreachableNodes(), Olympe::GetBBValue, GetComponentTypeID_Static(), GetNextNodeId(), HandleBranchSimulation(), HandleSequenceSimulation(), HandleSwitchSimulation(), HandleWhileSimulation(), Olympe::Literal, m_pathStack, m_tracedDataNodes, m_visitCount, Olympe::MathOp, Olympe::NODE_INDEX_NONE, Olympe::SetBBValue, Olympe::SubGraph, Olympe::Switch, TraceDataPinEvaluation(), ValidateAllBranches(), ValidateDataConnections(), Olympe::VSSequence, Olympe::Warning, and Olympe::While.

Referenced by Olympe::ExecutionTestPanel::RunExecutionTest().

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

◆ SimulateStep()

int32_t Olympe::GraphExecutionSimulator::SimulateStep ( const TaskGraphTemplate tmpl,
int32_t  currentNodeId,
LocalBlackboard blackboard,
const SimulationOptions options,
GraphExecutionTracer tracer 
)
private

Definition at line 220 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), and Olympe::NODE_INDEX_NONE.

+ Here is the call graph for this function:

◆ TraceDataConnection()

void Olympe::GraphExecutionSimulator::TraceDataConnection ( int32_t  sourceNodeId,
const std::string &  sourcePinName,
int32_t  targetNodeId,
const std::string &  targetPinName,
const TaskGraphTemplate tmpl,
GraphExecutionTracer tracer,
int32_t  depth 
)
private

Traces evaluation of a single data connection.

Parameters
sourceNodeIdNode providing the data.
sourcePinNameName of the output pin.
targetNodeIdNode receiving the data.
targetPinNameName of the input pin.
tmplThe task graph template.
tracerExecution tracer to record events.
depthCurrent recursion depth.

Definition at line 593 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static(), and TraceDataPinEvaluation().

Referenced by TraceDataPinEvaluation().

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

◆ TraceDataPinEvaluation()

void Olympe::GraphExecutionSimulator::TraceDataPinEvaluation ( int32_t  nodeId,
const TaskGraphTemplate tmpl,
GraphExecutionTracer tracer,
int32_t  depth = 0 
)
private

Recursively traces data pin evaluation for pure data nodes.

Evaluates and traces all incoming data pins of a node, and recursively traces their source nodes.

Parameters
nodeIdNode to trace data pins for.
tmplThe task graph template.
tracerExecution tracer to record events.
depthCurrent recursion depth.

Definition at line 484 of file GraphExecutionSimulator.cpp.

References Olympe::GetBBValue, GetComponentTypeID_Static(), m_tracedDataNodes, Olympe::MathOp, Olympe::NODE_INDEX_NONE, Olympe::SetBBValue, and TraceDataConnection().

Referenced by SimulateExecution(), and TraceDataConnection().

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

◆ ValidateAllBranches()

bool Olympe::GraphExecutionSimulator::ValidateAllBranches ( const TaskGraphTemplate tmpl,
std::vector< ValidationError > &  outErrors 
)

Validates all branch nodes in a graph.

Parameters
tmplThe TaskGraphTemplate to validate.
outErrors[out] Vector to append validation errors to.
Returns
true if all branches are valid.

Definition at line 325 of file GraphExecutionSimulator.cpp.

References Olympe::Branch, Olympe::Error, GetComponentTypeID_Static(), GetNextNodeId(), and Olympe::NODE_INDEX_NONE.

Referenced by SimulateExecution().

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

◆ ValidateConditionExpression()

bool Olympe::GraphExecutionSimulator::ValidateConditionExpression ( int32_t  nodeId,
const std::string &  expression 
)
private

Validates a condition expression.

Parameters
nodeIdNode containing the condition.
expressionCondition text to validate.
Returns
true if valid.

Definition at line 460 of file GraphExecutionSimulator.cpp.

References GetComponentTypeID_Static().

+ Here is the call graph for this function:

◆ ValidateDataConnections()

bool Olympe::GraphExecutionSimulator::ValidateDataConnections ( const TaskGraphTemplate tmpl,
std::vector< ValidationError > &  outErrors 
)

Validates all data connections in a graph.

Parameters
tmplThe TaskGraphTemplate to validate.
outErrors[out] Vector to append validation errors to.
Returns
true if all data connections are valid.

Definition at line 359 of file GraphExecutionSimulator.cpp.

References Olympe::Error, and GetComponentTypeID_Static().

Referenced by SimulateExecution().

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

Member Data Documentation

◆ m_pathStack

std::vector<int32_t> Olympe::GraphExecutionSimulator::m_pathStack
private

Current execution path.

Definition at line 218 of file GraphExecutionSimulator.h.

Referenced by SimulateExecution().

◆ m_tracedDataNodes

std::set<int32_t> Olympe::GraphExecutionSimulator::m_tracedDataNodes
private

Track data nodes already traced to prevent infinite recursion.

Definition at line 219 of file GraphExecutionSimulator.h.

Referenced by SimulateExecution(), and TraceDataPinEvaluation().

◆ m_visitCount

std::map<int32_t, int32_t> Olympe::GraphExecutionSimulator::m_visitCount
private

Track visits per node to detect loops.

Definition at line 217 of file GraphExecutionSimulator.h.

Referenced by SimulateExecution().


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