/**
 * $Id: baseobject.js 64367 2009-02-20 01:56:36Z kchiu $
 * $Author: kchiu $
 * $Revision: 64367 $
 * $Name$
 * $Date: 2009-02-19 17:56:36 -0800 (Thu, 19 Feb 2009) $
 *
 * @jsRequire interfaces.Interface
 *
 * BaseObject is a starter object for any JavaScript object
 * created. Once an object adds the BaseObject to its prototype
 * chain, it gains the functionality of all methods and variables
 * defined in this object, making BaseObject the perfect place
 * to incorporate other JavaScript libraries such as the Interface
 * library.
 *
 * @version    $Revision: 64367 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 * @see        interfaces.Interface
 */



/**
 * BaseObject Constructor / Definition
 *
 * @access public
 * @since  v1.1
 * @param  string      id
 * @return BaseObject
 */
function BaseObject(id) {
    // Method definitions
    this.getProperty = BaseObject_GetProperty;
    this.setProperty = BaseObject_SetProperty;
    this.getId       = BaseObject_GetId;
    this.setId       = BaseObject_SetId;
    // Member definitions
    this.properties = [];
    // Initialization
    this.setId(id);
    return this;
}

// Setup BaseObject prototype chain
BaseObject.prototype             = new Object;
BaseObject.prototype.constructor = BaseObject;
BaseObject.superclass            = Object.prototype;



/**
 * Returns the value of a property.
 *
 * @access public
 * @since  v1.1
 * @return mixed
 */
function BaseObject_GetProperty(name) {
    if (this.properties[name]) return this.properties[name];
    else                       return null;
}

/**
 * Sets the value of a property.
 *
 * @access public
 * @since  v1.1
 * @param  string  name
 * @param  mixed   value
 * return  boolean
 */
function BaseObject_SetProperty(name, value) {
    this.properties[name] = value;
    return true;
}

/**
 * Returns the id of the object.
 *
 * @access public
 * @since  v1.1
 * @return string
 */
function BaseObject_GetId() {
    return this.getProperty('id');
}

/**
 * Sets the id of the object.
 *
 * @access public
 * @since  v1.1
 * @param  string   id
 * @return boolean
 */
function BaseObject_SetId(id) {
    return this.setProperty('id', id);
}


/**
 * Extend the BaseObject class with any known included
 * functionality (for example Interface.implement)
 *
 * The reverse of this test can be found in interfaces.Interface
 * so that either file can be included first and the
 * functionality is still in place.
 */
if (typeof(Interface_Implement) == 'function') BaseObject.prototype.implement = Interface_Implement;
