-
Notifications
You must be signed in to change notification settings - Fork 0
Dependents
As the wiki discussed in previous pages, Juliagebra relies on a Dependency graph to manage itself, so we have to have a class for the nodes, and they are called and implemented by the Dependent abstract class.
This class is designed as abstract, because by itself it can't function in the graph. It has some abstract methods which must be specialized by inheriting from this class. So if one would like to add their own nodes to the graph, they would have to inherit from Dependent and have to define it's abstract methods.
Let's take a look at how this class is defined:
mutable struct Dependent
_graphID::Int
_graphParents::Vector{DependentDNA}
_dependentChain::DependentChain
_callback::Function
endAs we can see, every Dependent will be assigned to a graph via _graphID.
We also store who this node depends on in the Dependent graph (who has to be updated before updating this Node) in _graphParents.
The _callback function stores how the Dependent should react, when it is updated, evaluated in the Dependency graph.
The Dependent class also has a field with type DependentChain.
This object stores a reference to every other Dependent, Observed, Observers which have to be evaluated, updated, when an instance of this dependent is evaluated as a source node.
This object stores for efficient graph evaluation the Dependents and Observervers in a special way.
When the evalGraph function is called on a Dependent, the system will think that that specific dependent was changed by the User, so it will start updating the nodes that are reachable from this Dependent (by the three invariant rules described in the Dependency graph page).
Let's take a look at this example:
So calling evalGraph will produce the following callstack.
The onGraphEval method is meant to represent how a Dependent should update itself if it's _graphParents change state.
This method must be defined in inherited classes.
The afterGraphEval method is meant to represent what a Dependent should do after it is updated in the graph.
By default for standard Dependents, this methos does nothing.