From 4a319a340f8a68596d576031ce96948c353dcdcd Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 3 Jun 2019 14:41:14 +0200 Subject: [PATCH] Add dependency ckecking method, required for nghyd#212 --- src/nub.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/nub.ts b/src/nub.ts index 43970a54..fa0b6045 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -578,6 +578,27 @@ export abstract class Nub extends ComputeNode implements IObservable { return requiredNubs; } + /** + * Returns all Nubs whose parameters or results are targettes + * by the given one. + * (used for dependencies checking at session saving time) + */ + public getTargettedNubs(visited: string[] = []) { + const targettedNubs: Nub[] = []; + // prevent loops + if (! visited.includes(this.uid)) { + visited.push(this.uid); + + // inspect all target Nubs + for (const p of this.parameterIterator) { + if (p.valueMode === ParamValueMode.LINK && p.isReferenceDefined()) { + targettedNubs.push(p.referencedValue.nub); + } + } + } + return targettedNubs; + } + /** * Returns true if * - this Nub -- GitLab