/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
License:
LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
Authors:
* Sebastian Werner (wpbasti)
* Andreas Ecker (ecker)
************************************************************************ */
/* ************************************************************************
#module(core)
#load(qx.core.Init)
************************************************************************ */
/**
* The qooxdoo base object. All qooxdoo classes extend this one
*
* This class contains functions for:
*
* - logging
* - common getter/setter
* - user data
* - object destruction
*
*
* @param vAutoDispose {boolean ? true} wether the object should be disposed automatically by qooxdoo
*/
qx.OO.defineClass("qx.core.Object", Object,
function(vAutoDispose)
{
this._hashCode = qx.core.Object._counter++;
if (vAutoDispose !== false) {
qx.core.Object._db.push(this);
}
});
/*
---------------------------------------------------------------------------
DEFAULT SETTINGS
---------------------------------------------------------------------------
*/
qx.Settings.setDefault("enableDisposerDebug", false);
/* ************************************************************************
Class data, properties and methods
************************************************************************ */
qx.Class._counter = 0;
qx.Class._db = [];
/**
* Generate an unique key for the given object and return it.
* Sets object._hashCode to the generated key.
*
* @param o {Object}
* @return {int} unique key for the given object
*/
qx.Class.toHashCode = function(o)
{
if(o._hashCode != null) {
return o._hashCode;
}
return o._hashCode = qx.core.Object._counter++;
}
/**
* Class function which returns an object given its hash code
*
* @param hash {string} hash code of an object
*
* @returns {Object} the object whose hash is specified
*/
qx.Class.fromHashCode = function(hash) {
return qx.core.Object._db[hash];
}
/**
* Destructor. This method is called by qooxdoo on object destruction.
*
* Any class that holds ressources like links to DOM nodes must overwrite
* this method and free theese ressources.
*/
qx.Class.dispose = function()
{
// var logger = qx.dev.log.Logger.getClassLogger(qx.core.Object);
// logger.debug("Disposing Application");
// var vStart = (new Date).valueOf();
var vObject;
for (var i=qx.core.Object._db.length-1; i>=0; i--)
{
vObject = qx.core.Object._db[i];
if (vObject && vObject._disposed === false)
{
// logger.debug("Disposing: " + vObject);
vObject.dispose();
}
}
// logger.debug("Done in: " + ((new Date).valueOf() - vStart) + "ms");
}
/**
* Summary of allocated objects
*
* @return {string} summary of allocated objects.
*/
qx.Class.summary = function()
{
var vData = {};
var vCounter = 0;
for (var i=qx.core.Object._db.length-1; i>=0; i--)
{
vObject = qx.core.Object._db[i];
if (vObject && vObject._disposed === false)
{
if (vData[vObject.classname] == null)
{
vData[vObject.classname] = 1;
}
else
{
vData[vObject.classname]++;
}
vCounter++;
}
}
var vArrData = [];
for (var vClassName in vData) {
vArrData.push({ classname : vClassName, number : vData[vClassName] });
}
vArrData.sort(function(a, b) {
return b.number - a.number;
});
var vMsg = "Summary: (" + vCounter + " Objects)\n\n";
for (var i=0; i