net.lenkaspace.creeper.model
Class CRBaseModel

java.lang.Object
  extended by net.lenkaspace.creeper.model.CRBaseModel
Direct Known Subclasses:
CRBaseSituatedModel, CRWorld

public class CRBaseModel
extends java.lang.Object

Maintains an ID and can optionally hold children of the same class

Version:
2.0
Author:
Lenka Pitonakova contact@lenkaspace.net

Field Summary
 java.util.ArrayList<CRBaseModel> childModels
           
 int id
           
 
Constructor Summary
CRBaseModel(int id_)
          Constructor
 
Method Summary
 void addChildModel(CRBaseModel model_)
          Add child model to a maintained list.
 void clearChildren()
          Clear all arrays that store any child objects.
 int getId()
           
 boolean getIsRemoved()
           
 void onRunEnd(int runNumber_)
          Called by CRController each time a run ends.
 void onRunStart(int runNumber_)
          Called by CRController each time a run starts.
 void onTrialEnd(int trialNumber_, int runNumber_)
          Called by CRController each time a trial ends.
 void onTrialStart(int trialNumber_, int runNumber_)
          Called by CRController each time a trial starts.
 void removeChildModel(CRBaseModel model_)
          Remove a child model
 void setId(int id)
           
 void setIsRemoved(boolean is_)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public int id

childModels

public java.util.ArrayList<CRBaseModel> childModels
Constructor Detail

CRBaseModel

public CRBaseModel(int id_)
Constructor

Parameters:
id_ - int unique id
Method Detail

onRunStart

public void onRunStart(int runNumber_)
Called by CRController each time a run starts. Use this to reset self for a brand new simulation run and call onNewRun of children models.

Parameters:
runNumber_ - int new run number

onRunEnd

public void onRunEnd(int runNumber_)
Called by CRController each time a run ends. Use this to save any necessary data.

Parameters:
runNumber_ - int ending run number

onTrialStart

public void onTrialStart(int trialNumber_,
                         int runNumber_)
Called by CRController each time a trial starts. Use this to reset self for a new world environment and call onNewTrial of children models.

Parameters:
trialNumber_ - int new trial number
runNumber_ - int current run number

onTrialEnd

public void onTrialEnd(int trialNumber_,
                       int runNumber_)
Called by CRController each time a trial ends. Use this to save any necessary data.

Parameters:
trialNumber_ - int ending trial number
runNumber_ - int current run number

addChildModel

public void addChildModel(CRBaseModel model_)
Add child model to a maintained list. Use this to automatize cascade of events like onNewRun or onNewTrial.

Parameters:
model_ - CRBaseModel model

removeChildModel

public void removeChildModel(CRBaseModel model_)
Remove a child model

Parameters:
model_ - CRBaseModel model

clearChildren

public void clearChildren()
Clear all arrays that store any child objects. Subclasses should override this to implement clearing of any additional arrays


getId

public int getId()

setId

public void setId(int id)

setIsRemoved

public void setIsRemoved(boolean is_)

getIsRemoved

public boolean getIsRemoved()