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::GraphRuntimeInstance Class Reference

Manages single-threaded step-by-step execution of a TaskGraphTemplate. More...

#include <GraphRuntimeInstance.h>

+ Collaboration diagram for Olympe::GraphRuntimeInstance:

Public Member Functions

 GraphRuntimeInstance (const TaskGraphTemplate &graph)
 Constructs an instance bound to the given graph template.
 
void StartExecution ()
 Initialises the execution stack and marks the instance as running.
 
bool StepExecution ()
 Advances execution by one node.
 
bool IsExecuting () const
 Returns true while there are nodes left to execute.
 
void SetBlackboardVariable (const std::string &key, float value)
 Sets a Blackboard variable in the runtime environment.
 
void SetDynamicPinValue (const std::string &pinID, float value)
 Sets the runtime value of a dynamic data pin.
 
void AddBreakpoint (int32_t nodeID)
 Registers a breakpoint on a node.
 
void RemoveBreakpoint (int32_t nodeID)
 Removes a previously registered breakpoint.
 
bool IsBreakpointHit () const
 Returns true when execution is paused at a breakpoint.
 
void ResumeFromBreakpoint ()
 Resumes execution after a breakpoint.
 
const std::vector< int32_t > & GetActiveNodeIDs () const
 Returns the IDs of all nodes currently on the execution stack.
 
const std::string & GetLastError () const
 Returns the last error message produced during execution.
 

Private Member Functions

bool EvaluateBranchConditions (const TaskNodeDefinition &node)
 Evaluates all NodeConditionRefs on node and returns the result.
 

Private Attributes

const TaskGraphTemplatem_graph
 Bound graph template (not owned)
 
RuntimeEnvironment m_environment
 Blackboard + pin values.
 
std::vector< int32_tm_executionStack
 Active node IDs (front = next)
 
bool m_isExecuting
 True while stack is non-empty.
 
bool m_breakpointHit
 True when paused at a breakpoint.
 
bool m_skipBreakpointOnce
 Skip breakpoint check for one step after Resume.
 
std::set< int32_tm_breakpoints
 Registered breakpoint node IDs.
 
std::string m_lastError
 Last error from condition evaluation.
 

Detailed Description

Manages single-threaded step-by-step execution of a TaskGraphTemplate.

Definition at line 41 of file GraphRuntimeInstance.h.

Constructor & Destructor Documentation

◆ GraphRuntimeInstance()

Olympe::GraphRuntimeInstance::GraphRuntimeInstance ( const TaskGraphTemplate graph)
explicit

Constructs an instance bound to the given graph template.

Call StartExecution() to begin.

Parameters
graphImmutable graph template to execute.

Definition at line 19 of file GraphRuntimeInstance.cpp.

Member Function Documentation

◆ AddBreakpoint()

void Olympe::GraphRuntimeInstance::AddBreakpoint ( int32_t  nodeID)

Registers a breakpoint on a node.

When StepExecution() is about to process a node that has a breakpoint the execution pauses (StepExecution returns false without consuming the node) and IsBreakpointHit() returns true.

Parameters
nodeIDNode to break on.

Definition at line 131 of file GraphRuntimeInstance.cpp.

References m_breakpoints.

◆ EvaluateBranchConditions()

bool Olympe::GraphRuntimeInstance::EvaluateBranchConditions ( const TaskNodeDefinition node)
private

Evaluates all NodeConditionRefs on node and returns the result.

Conditions are combined with their LogicalOp (And / Or) in the order they appear in node.conditionRefs. The LogicalOp of the first entry (LogicalOp::Start) is ignored.

Returns
Combined boolean result; false on evaluation error.

Definition at line 170 of file GraphRuntimeInstance.cpp.

References GetComponentTypeID_Static().

Referenced by StepExecution().

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

◆ GetActiveNodeIDs()

const std::vector< int32_t > & Olympe::GraphRuntimeInstance::GetActiveNodeIDs ( ) const

Returns the IDs of all nodes currently on the execution stack.

Definition at line 156 of file GraphRuntimeInstance.cpp.

References m_executionStack.

◆ GetLastError()

const std::string & Olympe::GraphRuntimeInstance::GetLastError ( ) const

Returns the last error message produced during execution.

Empty when no error has occurred.

Definition at line 161 of file GraphRuntimeInstance.cpp.

References m_lastError.

◆ IsBreakpointHit()

bool Olympe::GraphRuntimeInstance::IsBreakpointHit ( ) const

Returns true when execution is paused at a breakpoint.

Definition at line 141 of file GraphRuntimeInstance.cpp.

References m_breakpointHit.

◆ IsExecuting()

bool Olympe::GraphRuntimeInstance::IsExecuting ( ) const

Returns true while there are nodes left to execute.

Definition at line 108 of file GraphRuntimeInstance.cpp.

References m_isExecuting.

◆ RemoveBreakpoint()

void Olympe::GraphRuntimeInstance::RemoveBreakpoint ( int32_t  nodeID)

Removes a previously registered breakpoint.

Parameters
nodeIDNode whose breakpoint to remove.

Definition at line 136 of file GraphRuntimeInstance.cpp.

References m_breakpoints.

◆ ResumeFromBreakpoint()

void Olympe::GraphRuntimeInstance::ResumeFromBreakpoint ( )

Resumes execution after a breakpoint.

Clears the breakpoint-hit flag so the next StepExecution() call will process the current node normally.

Definition at line 146 of file GraphRuntimeInstance.cpp.

References m_breakpointHit, and m_skipBreakpointOnce.

◆ SetBlackboardVariable()

void Olympe::GraphRuntimeInstance::SetBlackboardVariable ( const std::string &  key,
float  value 
)

Sets a Blackboard variable in the runtime environment.

Parameters
keyVariable identifier.
valueFloat value.

Definition at line 117 of file GraphRuntimeInstance.cpp.

References GetComponentTypeID_Static(), m_environment, and Olympe::RuntimeEnvironment::SetBlackboardVariable().

+ Here is the call graph for this function:

◆ SetDynamicPinValue()

void Olympe::GraphRuntimeInstance::SetDynamicPinValue ( const std::string &  pinID,
float  value 
)

Sets the runtime value of a dynamic data pin.

Parameters
pinIDPin UUID.
valueFloat value delivered by the connected node.

Definition at line 122 of file GraphRuntimeInstance.cpp.

References GetComponentTypeID_Static(), m_environment, and Olympe::RuntimeEnvironment::SetDynamicPinValue().

+ Here is the call graph for this function:

◆ StartExecution()

void Olympe::GraphRuntimeInstance::StartExecution ( )

Initialises the execution stack and marks the instance as running.

Uses the graph's RootNodeID as the first active node. If RootNodeID is NODE_INDEX_NONE the call is a no-op and IsExecuting() remains false.

Definition at line 31 of file GraphRuntimeInstance.cpp.

References Olympe::TaskGraphTemplate::EntryPointID, GetComponentTypeID_Static(), m_breakpointHit, m_executionStack, m_graph, m_isExecuting, m_lastError, m_skipBreakpointOnce, Olympe::NODE_INDEX_NONE, and Olympe::TaskGraphTemplate::RootNodeID.

+ Here is the call graph for this function:

◆ StepExecution()

bool Olympe::GraphRuntimeInstance::StepExecution ( )

Advances execution by one node.

Processes the top of the execution stack:

  • AtomicTask / other : follows NextOnSuccess (success path).
  • Branch : evaluates conditions -> Then or Else path.

Returns true when execution is still active after this step. Returns false when the stack becomes empty (execution complete or error).

Returns
true while executing; false when done.

Definition at line 52 of file GraphRuntimeInstance.cpp.

References Olympe::Branch, EvaluateBranchConditions(), GetComponentTypeID_Static(), Olympe::TaskGraphTemplate::GetNode(), m_breakpointHit, m_breakpoints, m_executionStack, m_graph, m_isExecuting, m_lastError, m_skipBreakpointOnce, and Olympe::NODE_INDEX_NONE.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_breakpointHit

bool Olympe::GraphRuntimeInstance::m_breakpointHit
private

True when paused at a breakpoint.

Definition at line 168 of file GraphRuntimeInstance.h.

Referenced by IsBreakpointHit(), ResumeFromBreakpoint(), StartExecution(), and StepExecution().

◆ m_breakpoints

std::set<int32_t> Olympe::GraphRuntimeInstance::m_breakpoints
private

Registered breakpoint node IDs.

Definition at line 170 of file GraphRuntimeInstance.h.

Referenced by AddBreakpoint(), RemoveBreakpoint(), and StepExecution().

◆ m_environment

RuntimeEnvironment Olympe::GraphRuntimeInstance::m_environment
private

Blackboard + pin values.

Definition at line 165 of file GraphRuntimeInstance.h.

Referenced by SetBlackboardVariable(), and SetDynamicPinValue().

◆ m_executionStack

std::vector<int32_t> Olympe::GraphRuntimeInstance::m_executionStack
private

Active node IDs (front = next)

Definition at line 166 of file GraphRuntimeInstance.h.

Referenced by GetActiveNodeIDs(), StartExecution(), and StepExecution().

◆ m_graph

const TaskGraphTemplate& Olympe::GraphRuntimeInstance::m_graph
private

Bound graph template (not owned)

Definition at line 164 of file GraphRuntimeInstance.h.

Referenced by StartExecution(), and StepExecution().

◆ m_isExecuting

bool Olympe::GraphRuntimeInstance::m_isExecuting
private

True while stack is non-empty.

Definition at line 167 of file GraphRuntimeInstance.h.

Referenced by IsExecuting(), StartExecution(), and StepExecution().

◆ m_lastError

std::string Olympe::GraphRuntimeInstance::m_lastError
private

Last error from condition evaluation.

Definition at line 171 of file GraphRuntimeInstance.h.

Referenced by GetLastError(), StartExecution(), and StepExecution().

◆ m_skipBreakpointOnce

bool Olympe::GraphRuntimeInstance::m_skipBreakpointOnce
private

Skip breakpoint check for one step after Resume.

Definition at line 169 of file GraphRuntimeInstance.h.

Referenced by ResumeFromBreakpoint(), StartExecution(), and StepExecution().


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