UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

71 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParamsEquation = void 0; const internal_modules_1 = require("../internal_modules"); /** * liste des paramètres d'une équation */ class ParamsEquation { constructor(parent) { this._paramMap = {}; this.parent = parent; } get nubUid() { if (!this.parent) { throw new Error("ParamsEquation.nubUid : equation has no parent Nub !"); } return this.parent.uid; } hasParameter(name) { for (const p of this) { if (p.symbol === name) { return true; } } return false; } get map() { return this._paramMap; } /** * Retrieves a parameter from its symbol */ get(name) { for (const s in this._paramMap) { if (s === name) { return this._paramMap[s]; } } return undefined; } checkParametersCalculability() { const res = []; for (const p of this) { if (p.calculability === undefined) { res.push(p.symbol); } } if (res.length > 0) { throw new Error("Calculability of parameter(s) " + res.toString() + " has not been defined"); } } [Symbol.iterator]() { return this.iterator; } get iterator() { return new internal_modules_1.ParamDefinitionIterator(this); } addParamDefinition(p, force = false) { if (force || !this.hasParameter(p.symbol)) { this._paramMap[p.symbol] = p; } } addParamDefinitions(ps) { for (const p of ps) { // Force update of the map index this.addParamDefinition(p, true); } } } exports.ParamsEquation = ParamsEquation; //# sourceMappingURL=params-equation.js.map