EvaluationOrder
class EvaluationOrder
Class for determining the evaluation order of entities based on their dependencies.
It uses Kahn's algorithm to compute a topological sort of the entities, ensuring that each entity is evaluated only after all its dependencies have been evaluated.
class Nodeprivate
This represents a node in the dependency graph of entities to be evaluated.
constructor Node
Constructs a node for the given entity.
| Node | ( | Entity * entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
entity |
The entity corresponding to this node. |
method add_dependency
Adds a dependency to this node.
| void add_dependency | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node that this node depends on. |
method is_readyconst
Checks if this node is ready to be evaluated.
| bool is_ready | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
True if this node has no dependencies, false otherwise. |
method remove_dependency
Removes a dependency from this node.
| void remove_dependency | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node to remove from the dependencies. |
member dependencies
The nodes that this node depends on.
member dependents
The nodes that depend on this node.
member entity
The entity corresponding to this node.
class TraversalPositionprivate
constructor TraversalPosition
| TraversalPosition | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
method has_nextconst
| bool has_next | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
method next
| Node * next | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
Node * |
member dependency_it
member node
constructor EvaluationOrderprivate
Constructs an EvaluationOrder object with the given starting entities.
| EvaluationOrder | ( | std::vector< Entity * > starting_entities | ); |
| PARAMETER | DESCRIPTION |
|---|---|
starting_entities |
The entities to start the evaluation from. |
method break_cycleprivate
Breaks a cycle in the dependency graph.
Report one cycle and break it.
| void break_cycle | ( | ); |
method compute_orderprivate
Computes the evaluation order of the entities.
This method implements Kahn's algorithm to perform a topological sort of the entities based on their dependencies.
| void compute_order | ( | ); |
method find_cycleprivate
| std::vector< Node * > find_cycle | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< Node * > |
method node_forprivate
Get a node for an entity in the dependency graph.
If the entity is already in the graph, its corresponding node is returned. Otherwise, a new node is created for the entity and added to the graph.
This method also recursively adds nodes for all dependencies of the entity to the graph.
| Node * node_for | ( | Entity * entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
entity |
The entity to add. |
| RETURNS | DESCRIPTION |
|---|---|
Node * |
The node corresponding to the added entity. |
method orderstatic
Computes the evaluation order of the given starting entities.
The dependencies of the starting entities are recursively explored to determine the order in which they should be evaluated.
| static std::vector< Entity * > order | ( | const std::vector< Entity * > & starting_entities | ); |
| PARAMETER | DESCRIPTION |
|---|---|
starting_entities |
The entities to start the evaluation from. |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< Entity * > |
A vector of entities in the order they should be evaluated. |
method place_nodeprivate
Places a node in the evaluation order.
This method adds the node's entity to the ordered_entities vector and removes the node from the dependency graph.
| void place_node | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node to place in the evaluation order. |
method remove_from_dependentsprivate
Removes a node from the dependencies of all its dependents.
It also moves all dependents that are now ready to be evaluated into the ready_nodes set.
| void remove_from_dependents | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node to remove from its dependents. |
member blocked_nodesprivate
The nodes that have dependencies and are not ready to be evaluated.
member nodesprivate
member ordered_entitiesprivate
The entities in the order they should be evaluated.
member ready_nodesprivate
The nodes that have no dependencies and are ready to be evaluated.
member sorted_entitiesprivate
The entities that have been added to the evaluation order.
These are stored as entities since their nodes are no longer needed and have been freed.
class Nodeprivate
This represents a node in the dependency graph of entities to be evaluated.
constructor Node
Constructs a node for the given entity.
| Node | ( | Entity * entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
entity |
The entity corresponding to this node. |
method add_dependency
Adds a dependency to this node.
| void add_dependency | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node that this node depends on. |
method is_readyconst
Checks if this node is ready to be evaluated.
| bool is_ready | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
True if this node has no dependencies, false otherwise. |
method remove_dependency
Removes a dependency from this node.
| void remove_dependency | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
The node to remove from the dependencies. |
member dependencies
The nodes that this node depends on.
member dependents
The nodes that depend on this node.
member entity
The entity corresponding to this node.
class TraversalPositionprivate
constructor TraversalPosition
| TraversalPosition | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
method has_nextconst
| bool has_next | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
method next
| Node * next | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
Node * |