////////////////////////////////////////////////////////////////////////
//
// Filename: BCBase.js
// Purpose : Base class of all classes
// Method  : Lookuptable, valAssign
//
// Author  : J.van.der.Steen@gobase.org
// Date    : 2010-03-07
//
////////////////////////////////////////////////////////////////////////

var BCBase = Class.create(
{

    initialize: function(values)
    {
        this.valAssign(values, "type", "bcbase" + (this.type === undefined ? '' : '-' + this.type));

        this.guid = config.lookupTable.add(this);
    }

    /**
     * Assign value based on possibly existing property in supplied object.
     * Assign the supplied default value otherwise.
     */
,   valAssign: function(values, val, defval)
    {
        try {
            if (values[val] !== undefined && values[val] !== null) {
                this[val] = values[val];
            } else {
                this[val] = defval;
            }
        }
        catch(err) {
            var error = '';
            for (prop in err) {
                if (err[prop] !== undefined) {
                    error += " " + err[prop] + ";";
                }
            }
            debug("Error: valAssign(): [" + error + "]");
        }
    }

} ) ;


