I am porting my application classes by hand over to the new .8 and on my
second class I ran into a bit of trouble. First, it is subclassed from a
qooxdoo class that is not longer available, qx.util.manager.Object. Since
this is a class that mostly just manages lists of objects I changed it to
descend from qx.core.Object. That part was fine, but every method in my
members: section are coming up as "is not a function" when I try and use
them. Should I have subclassed it from another class? The methods all show
up in the API viewer but just don't show up when I try and use them. Here is
the class code (it is a modification of the pooling class that I think came
from the contributions area):
Thanks,
Jim
/* ************************************************************************
Solumina Web Express Publisher
swep.Pool
http://Solumina.com
Copyright:
2007-2008 iBASEt
Authors:
* Jim Hunter
* Greg Stevenson
* * modified from a contribution to the qooxdoo project
************************************************************************ */
/**
* This is the heart of pooling objects in SWEP.
* You can request an object from this class and if that object
* does not already exist in a pool it will create one and return it to you.
*
* It also allows for the pooling of tables to really help speed things up.
*/
qx.Class.define("swep.Pool", {
type: "singleton",
//extend: qx.util.manager.Object,
extend: qx.core.Object,
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
construct: function()
{
//qx.util.manager.Object.call(this);
qx.core.Object.call(this);
//
************************************************************************
// OBJECT POOL
//
************************************************************************
this._pool = {};
},
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties: {
/*
---------------------------------------------------------------------------
PROPERTIES
---------------------------------------------------------------------------
*/
/** A Map of classname : poolSize. */
poolSizes: {
_legacy: true,
type: "object"
}
},
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members: {
/*
---------------------------------------------------------------------------
IMPL
---------------------------------------------------------------------------
*/
/**
* @param vClassname {String} The name of the Object type to count.
*
* @return {Integer} The number of instance of type vClassname that
are currently
* pooled.
*/
countObjectsOfType: function(vClassname)
{
// this.debug("countObjectsOfType() vClassname=" + vClassname );
// this.debug("countObjectsOfType() this._pool["+vClassname+"]="
+ this._pool[vClassname]);
var count = 0;
if (this._pool[vClassname])
{
count = this._pool[vClassname].length;
}
return count;
},
/**
* This method finds and returns an instance of a requested type in
the pool,
* if there is one. Note that the pool determines which instance
(if any) to
* return to the client. The client cannot get a specific instance
from the
* pool.
*
* @param vClassname {String} The name of the Object type to return.
*
* @return {Object} An instance of the requested type, or null if no
such instance
* exists in the pool.
*/
getObjectOfType: function(vClassname, ID, aWidth)
{
var obj = null;
var ToolList = ["swep.sfDispatchTool", "swep.sfUDVPageForm",
"swep.sfDiscrepencyTool"];
if (this._pool[vClassname])
{
if (this._pool[vClassname].length > 0)
{
obj = this._pool[vClassname].pop();
obj.isPooled = true;
}
else
{
if (ToolList.indexOf(vClassname) != -1)
obj = eval('new ' + vClassname + '("' + ID + '", ' +
aWidth + ')')
else
obj = eval('new ' + vClassname);
}
}
else
{
if (ToolList.indexOf(vClassname) != -1)
obj = eval('new ' + vClassname + '("' + ID + '", ' +
aWidth + ')')
else
obj = eval('new ' + vClassname);
}
return obj;
},
/**
* This function returns an instance of a table.
* It differs from normal pooling in that it returns
* an instance of a specific table based on the tableID passed in.
* Tables can't be re-used if the columns are different, but can be
re-used
* by simply changing the data.
*
* @param tableID {String} This is the ID given by the server
*/
getPooledTable: function(tableID)
{
var obj = null;
if (this._pool[tableID])
{
if (this._pool[tableID].length > 0)
obj = this._pool[tableID].pop();
else
{
//eval('var tm = new qx.ui.table.model.Simple()');
obj = null; //eval('new qx.ui.table.Table(tm)');
}
}
return obj;
},
/**
* This method places an Object in a pool of Objects of its type.
Note that
* once an instance has been pooled, there is no means to get that
exact
* instance back. The instance may be discarded for garbage
collection if
* the pool of its type is already full.
*
* It is assumed that no other references exist to this Object, and
that it will
* not be used at all while it is pooled.
*
* @param vObject {Object} An Object instance to pool.
*/
poolObject: function(vObject)
{
// Do some checks to make sure the caller has met their
obligations.
if (vObject == null)
{
this.warn("poolObject() Cannot pool " + vObject);
return;
}
var classname = vObject.classname;
if (classname == 'qx.ui.table.Table')
classname = vObject.tableID;
if (classname == 'swep.sfGrid')
classname = vObject.tableID;
this._ensurePoolOfType(classname);
if ((classname != 'qx.ui.table.Table') && (classname !=
'swep.sfGrid'))
removeAllListeners(vObject);
// Check to see whether this instance is already in the pool
//
// Note that iterating over this._pool[classname].length only
works because
// there are never any empty Array elements in the pool.
var pooled = false;
for (i = 0, l = this._pool[classname].length; i < l; i++)
{
if (this._pool[classname][i] == vObject)
{
this.warn("poolObject() Cannot pool " + vObject + "
because it is already in the pool.");
pooled = true;
break;
}
}
// Check to see whether the pool for this type is already full
var full = false; //this._isPoolFull(classname);
if (full)
{
this.warn("poolObject() Cannot pool " + vObject + " because
the pool is already full.");
}
// Pool instance if possible
if (!pooled && !full)
{
this._pool[classname].push(vObject);
}
else
{
this.warn("poolObject() Cannot pool " + vObject + "; lost an
instance of type " + classname);
}
},
/*
---------------------------------------------------------------------------
IMPL HELPERS
---------------------------------------------------------------------------
*/
/**
* This method checks whether the pool for a given class of Objects
is
* already full. As a side-effect of calling this method a pool
will
* be created if it does not already exist.
*
* @param vClassname {String} The name of a type of Object.
*
* @return {Boolean} True if the pool is already full, otherwise
false. Note
* that is no upper limit is defined for the type, this
method will
* always return false.
*/
_isPoolFull: function(vClassname)
{
this._ensurePoolOfType(vClassname);
var isPoolFull = false;
if (this.getPoolSizes()[vClassname])
{
isPoolFull = this._pool[vClassname].length >=
this.getPoolSizes()[vClassname];
}
else
{
// No pool size defined
this.warn("_isPoolFull() No pool size defined for type " +
vClassname);
}
return isPoolFull;
},
/**
* This method ensures that there is a pool for Objects of a given
type. If a
* pool doesn't already exist, this method will create it.
*
* @param vClassname {String} The name of a type of Object.
*/
_ensurePoolOfType: function(vClassname)
{
if (!this._pool[vClassname])
{
this._pool[vClassname] = [];
}
},
/**
* This method can be used to see the current state of the Pool.
* It returns all of the current classes being pooled and how many
* instances of each class are in the pool.
* This is intended to be used for testing only.
*/
getPoolStatus: function()
{
// returns a list of pools with their lengths, used totally for
testing to see if all objects are being created
// using the pool and also being added back into the pool.
// if the pool count keeps going up then the objects are not
being created from the pool
// or they are not getting disposed of inside disposeChildren
s = '';
for (var k in this._pool)
{
s = s + this._pool[k].length + ' ' + k + '\n';
}
return s;
}
}
});
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel