2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Object = require ('./object');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* List of Sql.Object
|
|
|
|
**/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Object
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,objects: []
|
|
|
|
|
|
|
|
,add: function (object)
|
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
this.objects.push (object.ref ());
|
|
|
|
object.on ('changed', this._onObjectChange, this);
|
|
|
|
this._onObjectChange ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,get: function (i)
|
|
|
|
{
|
|
|
|
return objects[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
,getArray: function ()
|
|
|
|
{
|
|
|
|
return this.objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
,remove: function (i)
|
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
this._unrefObject (this.objects.splice (i, 1));
|
|
|
|
this._onObjectChange ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2015-07-28 19:14:26 +00:00
|
|
|
,_onObjectChange: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
this.signalEmit ('changed');
|
|
|
|
}
|
|
|
|
|
|
|
|
,isReady: function ()
|
|
|
|
{
|
|
|
|
var o = this.objects;
|
|
|
|
|
|
|
|
if (o.length == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (var i = 0; i < o.length; i++)
|
|
|
|
if (!o[i].isReady ())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-28 19:14:26 +00:00
|
|
|
|
|
|
|
,_unrefObject: function (object)
|
|
|
|
{
|
|
|
|
object.disconnect ('changed', this._onObjectChange, this);
|
|
|
|
object.unref ();
|
|
|
|
}
|
|
|
|
|
2015-08-17 18:02:14 +00:00
|
|
|
,_destroy: function ()
|
2015-07-28 19:14:26 +00:00
|
|
|
{
|
|
|
|
for (var i = 0; i < this.objects.length; i++)
|
|
|
|
this._unrefObject (this.objects[i]);
|
|
|
|
|
|
|
|
this.parent ();
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|