function WidgetInputData() {
    var terminals = {};
    var data = {};
    var index = {};
    var counter = 0;

    /**
     * Add an input terminal
     * @terminal: name of the input terminal
     * @source: name(s) of output terminal(s) connected to the concerning input terminal (It is an array of String (if @multiple is true) or a single String)
     */
    this.addTerminal = function (terminal, multiple, source) {
        terminals[terminal] = {"terminal": terminal, "multiple": multiple};
        if (multiple) {
            counter += source.length;
            data[terminal] = [];
            for (var i = 0; i < source.length; ++i) {
                data[terminal].push(null);
                index[source[i]] = i;
            }
        } else {
            counter++;
            data[terminal] = null;
        }
    }

    this.receiveData = function (terminal, source, d) {
        if (terminals[terminal]["multiple"]) {
            if (data[terminal][index[source]] == null)
                counter--;
            data[terminal][index[source]] = d;
        } else {
            if (data[terminal] == null)
                counter--;
            data[terminal] = d;
        }
    }

    this.clearInputData = function () {
        counter = 0;
        for (var terminal in terminals) {
            if (terminals[terminal]["multiple"]) {
                for (var p in index) {
                    counter++;
                }
                data[terminal] = [];
            } else {
                counter++;
                data[terminal] = null;
            }
        }
    }

    /**
     * Check if all terminals has received data
     */
    this.isAllDataReceived = function () {
        return (counter == 0);
    }

    this.getData = function () {
        return data;
    }
}
/**
 * Util class to manipulate the collected input of a client widget (for all of its input terminals)
 */
Util class to manipulate the collected input of a client widget (for all of its input terminals)
Util class to manipulate the collected input of a client widget ( for all of its input terminals )
function WidgetInputData() {
    var terminals = {};
    var data = {};
    var index = {};
    var counter = 0;
    this.addTerminal = function (terminal, multiple, source) {
        terminals[terminal] = {"terminal": terminal, "multiple": multiple};
        if (multiple) {
            counter += source.length;
            data[terminal] = [];
            for (var i = 0; i < source.length; ++i) {
                data[terminal].push(null);
                index[source[i]] = i;
            }
        } else {
            counter++;
            data[terminal] = null;
        }
    }
    this.receiveData = function (terminal, source, d) {
        if (terminals[terminal]["multiple"]) {
            if (data[terminal][index[source]] == null)
                counter--;
            data[terminal][index[source]] = d;
        } else {
            if (data[terminal] == null)
                counter--;
            data[terminal] = d;
        }
    }
    this.clearInputData = function () {
        counter = 0;
        for (var terminal in terminals) {
            if (terminals[terminal]["multiple"]) {
                for (var p in index) {
                    counter++;
                }
                data[terminal] = [];
            } else {
                counter++;
                data[terminal] = null;
            }
        }
    }
    this.isAllDataReceived = function () {
        return (counter == 0);
    }
    this.getData = function () {
        return data;
    }
}
function WidgetInputData ( ) { var terminals = { } ; var data = { } ; var index = { } ; var counter = 0 ; this . addTerminal = function ( terminal , multiple , source ) { terminals [ terminal ] = { "terminal" : terminal , "multiple" : multiple } ; if ( multiple ) { counter += source . length ; data [ terminal ] = [ ] ; for ( var i = 0 ; i < source . length ; ++ i ) { data [ terminal ] . push ( null ) ; index [ source [ i ] ] = i ; } } else { counter ++ ; data [ terminal ] = null ; } } this . receiveData = function ( terminal , source , d ) { if ( terminals [ terminal ] [ "multiple" ] ) { if ( data [ terminal ] [ index [ source ] ] == null ) counter -- ; data [ terminal ] [ index [ source ] ] = d ; } else { if ( data [ terminal ] == null ) counter -- ; data [ terminal ] = d ; } } this . clearInputData = function ( ) { counter = 0 ; for ( var terminal in terminals ) { if ( terminals [ terminal ] [ "multiple" ] ) { for ( var p in index ) { counter ++ ; } data [ terminal ] = [ ] ; } else { counter ++ ; data [ terminal ] = null ; } } } this . isAllDataReceived = function ( ) { return ( counter == 0 ) ; } this . getData = function ( ) { return data ; } }
Util class to manipulate the collected input of a client widget (for all of its input terminals)
Util class to manipulate the collected input of a client widget ( for all of its input terminals )
/**
     * Add an input terminal
     * @terminal: name of the input terminal
     * @source: name(s) of output terminal(s) connected to the concerning input terminal (It is an array of String (if @multiple is true) or a single String)
     */ /**
     * Check if all terminals has received data
     */