-
Notifications
You must be signed in to change notification settings - Fork 0
Plans
The Dependent, Observed, Observer, classes require special construction because theese classes can have invalid states. The Plan group of classes help with defining pre-made build methods, which help with this. To use this automatic building system, we have to assign Dependents, Observed, Observers to Plans.
Define Plan2Observer, so that the system knows which Observer to assign to a Dependent created from a Plan.
Define Plan2Dependent, so that the system knows what Dependent to create from what Plan.
Building of normal Dependents from Plans happens like this:
function buildFromPlan!(plan::PlanDNA,graph::DependentGraphDNA)
dependent = Plan2Dependent(plan)
add!!(graph,dependent)
_Plan_(plan)._dependent = dependent
return dependent
endSo the Dependent is created, then assigned to a Dependency Graph.
Building of Observer - Observed pairs from Plans happens like this:
function buildFromPlan!(plan::ObservedPlanDNA,graph::DependentGraphDNA,builder::ObserverBuilderDNA)
observer = Plan2Observer(builder,plan)
observed = Plan2Dependent(plan)
add!!(observer,observed)
add!!(graph,observed)
_Plan_(plan)._dependent = observed
return (observer,observed)
endAs we can see, first an Observed is created, or asked for depending on what an ObserverBuilder gives us. Then an Observed is created. After That the Observed is assigned to the Observer, then to the Dependency graph.
Note that we have to have an ObserverBuilder class, which manages what (new) Observer should get which Observed created from that ObservedPlan.