UNPKG

@metacell/geppetto-meta-core

Version:

The core functionality of geppetto-meta to build and simulate neuroscience data and models.

75 lines (71 loc) 1.68 kB
/** * Client class use to represent a composite type. * * @module model/CompositeType * @author Giovanni Idili */ import Resources from '../Resources'; import Type from './Type'; function CompositeType(options) { Type.prototype.constructor.call(this, options); this.variables = options.variables !== 'undefined' ? options.variables : []; } CompositeType.prototype = Object.create(Type.prototype); CompositeType.prototype.constructor = CompositeType; /** * Get variables * * @command CompositeType.getChildren() * * @returns {List<Variable>} - List of variables * */ CompositeType.prototype.getVariables = function () { return this.variables; }; /** * Check if the composite contains a given variable * * @param varId * @returns {boolean} */ CompositeType.prototype.hasVariable = function (varId) { var vars = this.getVariables(); var match = false; for (var i = 0; i < vars.length; i++) { if (vars[i].getId() === varId) { match = true; } } return match; }; /** * Get combined children * * @command CompositeType.getChildren() * * @returns {List<Object>} - List of children * */ CompositeType.prototype.getChildren = function () { return this.variables; }; /** * Return connections * * @command CompositeType.getConnections() * * @returns {Boolean} * */ CompositeType.prototype.getConnections = function () { var connectionVariables = []; for (var v in this.getVariables()) { var variable = this.getVariables()[v]; if (variable.getType().getMetaType() == Resources.CONNECTION_TYPE) { connectionVariables.push(variable); } } return connectionVariables; }; export default CompositeType;