API reference

SystemDAG

SystemDAG

class SystemDAG
Manages the dependency graph of systems in the Spatial SDK.
SystemDAG (Directed Acyclic Graph) is responsible for:
  • Tracking system dependencies and their relationships
  • Ensuring proper execution order based on dependencies
  • Detecting and preventing dependency cycles
  • Organizing systems into priority groups for execution
Systems can specify dependencies using mustRunBefore and mustRunAfter relationships, which this class resolves into a valid execution order.

Constructors

NameSummary
SystemDAG
constructor()

Functions

NameSummary
addSystem
fun addSystem(system: SystemBase, priorityGroup: PriorityGroup = PriorityGroup.NORMAL)

Adds a system to the dependency graph.
findSystem
fun <T : SystemBase> findSystem(clazz: KClass<T>): T

Finds a system in the dependency graph. Throws an exception if the system is not found.
removeSystem
inline fun <T : SystemBase> removeSystem(): Boolean

Removes a system from the dependency graph using reified type parameter.



fun <T : SystemBase> removeSystem(clazz: KClass<T>): Boolean

Removes a system from the dependency graph.
setEarlySystems
fun setEarlySystems(earlySystems: List<SystemBase>)

Sets the list of early systems that run before all other systems.
setLateSystems
fun setLateSystems(lateSystems: List<SystemBase>)

Sets the list of late systems that run after all other systems.
topologicalSortWithCycleDetection
fun topologicalSortWithCycleDetection(): MutableList<SystemBase>

Performs a topological sort of the systems based on their dependencies.
tryFindSystem
fun <T : SystemBase> tryFindSystem(clazz: KClass<T>): T?

Attempts to find a system in the dependency graph.