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

Immutable, shareable task graph asset. More...

#include <TaskGraphTemplate.h>

+ Collaboration diagram for Olympe::TaskGraphTemplate:

Public Member Functions

bool Validate () const
 Validates the structural integrity of the template.
 
const TaskNodeDefinitionGetNode (int32_t nodeId) const
 Returns a pointer to the node with the given ID, or nullptr.
 
void BuildLookupCache ()
 Rebuilds the internal ID-to-node lookup map from the Nodes vector.
 
int SanitizeExecConnections ()
 Phase 24.3 - Poka-Yoke: Sanitizes exec connections to remove invalid links.
 

Public Attributes

std::string Name
 Friendly name of this template (e.g. "PatrolBehaviour")
 
std::string Description
 Optional human-readable description.
 
std::vector< VariableDefinitionLocalVariables
 Blackboard schema.
 
std::vector< TaskNodeDefinitionNodes
 All graph nodes.
 
int32_t RootNodeID = NODE_INDEX_NONE
 ID of the root node (must exist in Nodes)
 
int32_t EntryPointID = NODE_INDEX_NONE
 ID of the EntryPoint node (for VS graphs)
 
std::string GraphType = "BehaviorTree"
 Graph type: "BehaviorTree" (legacy) or "VisualScript" (ATS VS)
 
std::vector< BlackboardEntryBlackboard
 Local blackboard declared in this graph.
 
std::vector< ExecPinConnectionExecConnections
 Explicit exec connections (ATS VS only)
 
std::vector< DataPinConnectionDataConnections
 Explicit data connections (ATS VS only)
 
bool IsSubGraph = false
 True if this template is a SubGraph.
 
std::vector< SubGraphParameterDefInputParameters
 Declared inputs (for subgraphs)
 
std::vector< SubGraphParameterDefOutputParameters
 Declared outputs (for subgraphs)
 
std::vector< ConditionPresetPresets
 Presets are now stored in the graph JSON, not in external files.
 
json GlobalVariableValues = json::object()
 Stores JSON representation of global variable values for this specific graph instance.
 

Private Attributes

std::unordered_map< int32_t, const TaskNodeDefinition * > m_nodeLookup
 Fast lookup: node ID -> pointer into Nodes vector.
 

Detailed Description

Immutable, shareable task graph asset.

Load once, share across many TaskRunner instances. Call BuildLookupCache() after populating Nodes so that GetNode() runs in O(1). Call Validate() before using the template to catch structural errors early.

Definition at line 178 of file TaskGraphTemplate.h.

Member Function Documentation

◆ BuildLookupCache()

void Olympe::TaskGraphTemplate::BuildLookupCache ( )

Rebuilds the internal ID-to-node lookup map from the Nodes vector.

Must be called after Nodes is populated or modified.

Definition at line 81 of file TaskGraphTemplate.cpp.

References GetComponentTypeID_Static(), m_nodeLookup, Name, Nodes, and SYSTEM_LOG.

Referenced by Olympe::BTtoVSMigrator::Convert(), Olympe::VisualScriptEditorPanel::LoadTemplate(), and Olympe::VisualScriptEditorPanel::SyncTemplateFromCanvas().

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

◆ GetNode()

const TaskNodeDefinition * Olympe::TaskGraphTemplate::GetNode ( int32_t  nodeId) const

Returns a pointer to the node with the given ID, or nullptr.

Requires BuildLookupCache() to have been called after the last modification to Nodes.

Parameters
nodeIdNode identifier.
Returns
Pointer to the node, or nullptr if not found.

Definition at line 71 of file TaskGraphTemplate.cpp.

References GetComponentTypeID_Static(), and m_nodeLookup.

Referenced by Olympe::VisualScriptEditorPanel::RebuildLinks(), Olympe::VisualScriptEditorPanel::RemoveLink(), and Olympe::GraphRuntimeInstance::StepExecution().

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

◆ SanitizeExecConnections()

int Olympe::TaskGraphTemplate::SanitizeExecConnections ( )

Phase 24.3 - Poka-Yoke: Sanitizes exec connections to remove invalid links.

Detects and removes exec connections that violate the data-pure node constraints:

  • Removes any exec-in connections TO data-pure nodes (GetBBValue, MathOp)
  • Removes any exec-out connections FROM data-pure nodes

Logs all removed connections to SYSTEM_LOG for debugging. Safe to call multiple times (idempotent).

Returns
Number of invalid connections that were removed.

Definition at line 98 of file TaskGraphTemplate.cpp.

References ExecConnections, Olympe::GetBBValue, GetComponentTypeID_Static(), Olympe::MathOp, Nodes, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ Validate()

bool Olympe::TaskGraphTemplate::Validate ( ) const

Validates the structural integrity of the template.

Rules checked:

  • Nodes vector must not be empty.
  • RootNodeID must reference an existing node.
  • Every ChildrenID referenced by any node must reference an existing node.
Returns
true if all validation rules pass; false otherwise.

Definition at line 21 of file TaskGraphTemplate.cpp.

References Olympe::TaskNodeDefinition::ChildrenIDs, GetComponentTypeID_Static(), Name, Nodes, RootNodeID, and SYSTEM_LOG.

+ Here is the call graph for this function:

Member Data Documentation

◆ Blackboard

std::vector<BlackboardEntry> Olympe::TaskGraphTemplate::Blackboard

◆ DataConnections

std::vector<DataPinConnection> Olympe::TaskGraphTemplate::DataConnections

◆ Description

std::string Olympe::TaskGraphTemplate::Description

Optional human-readable description.

Definition at line 186 of file TaskGraphTemplate.h.

◆ EntryPointID

int32_t Olympe::TaskGraphTemplate::EntryPointID = NODE_INDEX_NONE

◆ ExecConnections

std::vector<ExecPinConnection> Olympe::TaskGraphTemplate::ExecConnections

◆ GlobalVariableValues

json Olympe::TaskGraphTemplate::GlobalVariableValues = json::object()

Stores JSON representation of global variable values for this specific graph instance.

These are entity-specific values (different from global registry defaults). Loaded from "globalVariableValues" in graph JSON during deserialization. Restored to EntityBlackboard after initialization.

Definition at line 224 of file TaskGraphTemplate.h.

Referenced by Olympe::VisualScriptEditorPanel::LoadTemplate(), Olympe::VisualScriptEditorPanel::Save(), Olympe::VisualScriptEditorPanel::SaveAs(), and Olympe::VisualScriptEditorPanel::SerializeAndWrite().

◆ GraphType

std::string Olympe::TaskGraphTemplate::GraphType = "BehaviorTree"

Graph type: "BehaviorTree" (legacy) or "VisualScript" (ATS VS)

Definition at line 197 of file TaskGraphTemplate.h.

Referenced by Olympe::BTtoVSMigrator::Convert().

◆ InputParameters

std::vector<SubGraphParameterDef> Olympe::TaskGraphTemplate::InputParameters

Declared inputs (for subgraphs)

Definition at line 210 of file TaskGraphTemplate.h.

◆ IsSubGraph

bool Olympe::TaskGraphTemplate::IsSubGraph = false

True if this template is a SubGraph.

Definition at line 209 of file TaskGraphTemplate.h.

◆ LocalVariables

std::vector<VariableDefinition> Olympe::TaskGraphTemplate::LocalVariables

Blackboard schema.

Definition at line 188 of file TaskGraphTemplate.h.

◆ m_nodeLookup

std::unordered_map<int32_t, const TaskNodeDefinition*> Olympe::TaskGraphTemplate::m_nodeLookup
private

Fast lookup: node ID -> pointer into Nodes vector.

Definition at line 277 of file TaskGraphTemplate.h.

Referenced by BuildLookupCache(), and GetNode().

◆ Name

std::string Olympe::TaskGraphTemplate::Name

◆ Nodes

std::vector<TaskNodeDefinition> Olympe::TaskGraphTemplate::Nodes

◆ OutputParameters

std::vector<SubGraphParameterDef> Olympe::TaskGraphTemplate::OutputParameters

Declared outputs (for subgraphs)

Definition at line 211 of file TaskGraphTemplate.h.

◆ Presets

std::vector<ConditionPreset> Olympe::TaskGraphTemplate::Presets

Presets are now stored in the graph JSON, not in external files.

This makes blueprints self-contained with no external file dependencies. Populated during LoadTemplate() from "presets" array in graph JSON.

Definition at line 217 of file TaskGraphTemplate.h.

Referenced by Olympe::VisualScriptEditorPanel::Initialize(), Olympe::VisualScriptEditorPanel::LoadTemplate(), Olympe::VisualScriptEditorPanel::SerializeAndWrite(), and Olympe::VisualScriptEditorPanel::SyncPresetsFromRegistryToTemplate().

◆ RootNodeID

int32_t Olympe::TaskGraphTemplate::RootNodeID = NODE_INDEX_NONE

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