//================================= CLASS CONSTRUCTOR ========================================
function DnlEntity()
{
//MEMBER VARIABLES
 this.position = null;
 this.parent = null;
 this.id = null;
 this.status = null;
 this.eStatusChanged = null;
 this.operation = null;

 this.initialize();
}

//====================================== STATIC ==============================================
//CONSTANTS
DnlEntity.STATUS_NOTREADY     = 0;
DnlEntity.STATUS_MUSTDOWNLOAD = 1;
DnlEntity.STATUS_DOWNLOADING  = 2;
DnlEntity.STATUS_READY        = 3;

//====================================== MEMBERS =============================================
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GETTER/SETTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ METHODS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DnlEntity.prototype.setDefaults = function()
{
 this.position = null;
 this.parent = null;
 this.id = null;
 this.status = null;
 this.eStatusChanged = null;
 this.operation = null;
}

DnlEntity.prototype.initialize = function()
{
 this.position = -1;
 this.id = 0;
 this.status = DnlEntity.STATUS_NOTREADY;
}

DnlEntity.prototype.getPosition = function()
{
 return this.position;
}

DnlEntity.prototype.setPosition = function(iposition)
{
 this.position = iposition;
}

DnlEntity.prototype.getParent = function()
{
 return this.parent;
}

DnlEntity.prototype.setParent = function(iparent)
{
 this.parent = iparent;
}

DnlEntity.prototype.getOperation = function()
{
 return this.operation;
}

DnlEntity.prototype.setOperation = function(ioperation)
{
 this.operation = ioperation;
}

DnlEntity.prototype.getId = function()
{
 return this.id;
}

DnlEntity.prototype.setId = function(iid)
{
 this.id = iid;
}

DnlEntity.prototype.getStatus = function()
{
 return this.status;
}

DnlEntity.prototype.setStatus = function(istatus)
{
 if (this.status >= istatus)
  return;
 this.status = istatus;
 if (this.eStatusChanged != null)
  this.eStatusChanged.method(this.eStatusChanged.context,this);
}

DnlEntity.prototype.setEStatusChanged = function(ieStatusChanged)
{
 this.eStatusChanged = ieStatusChanged;
}

DnlEntity.prototype.query = function(icallback)
{
 if (icallback(this) == true)
  return this;
 return null;
}

/* === Because we'll never call these methods from a leaf node we'll comment these!
DnlEntity.prototype.createDnlEntity = function()
{
//We don't have children ... a new child DnlEntity can't be created here!
 return null;
}

DnlEntity.prototype.add = function(iDnlEntity)
{
//We can't add an DnlEntity here(it's a leaf node)
}
*/

DnlEntity.prototype.remove = function()
{
//Notifying the parent of this removal ...
 if (this.parent != null)
  this.parent.onChildRemoved(this);
//Finalizing ...
 this.finalize();
}

/*
DnlEntity.prototype.onChildRemoved = function(iDnlEntity)
{
//We don't have children ...
}

DnlEntity.prototype.getChildCount = function()
{
 return 0;
}

DnlEntity.prototype.getChild = function(iposition)
{
//We can't get any child ... returning null...
 return null;
}
*/

DnlEntity.prototype.finalize = function()
{
//Setting the defaults ...
 this.setDefaults();
}
