Package modelarium
Class ModelElement
java.lang.Object
modelarium.ModelElement
- All Implemented Interfaces:
DeepCopyable<ModelElement>
- Direct Known Subclasses:
Agent,Environment
Abstract base class for all model elements in the simulation.
Each model element represents either an Agent
or the Environment and holds a unique name,
a set of attributes, and a reference to its ModelElementAccessor.
-
Constructor Summary
ConstructorsConstructorDescriptionModelElement(String name, AttributeSetCollection attributeSetCollection) Constructs a model element with the given name and attribute set collection. -
Method Summary
Modifier and TypeMethodDescriptiongetName()abstract voidrun()Defines the logic to be executed on each simulation tick.voidsetModelElementAccessor(ModelElementAccessor modelElementAccessor) Sets the model element accessor, which provides external access to model context, data, and messaging.voidsetup()Initialises the attribute set for this element by calling its setup method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface utils.DeepCopyable
deepCopy
-
Constructor Details
-
ModelElement
Constructs a model element with the given name and attribute set collection.- Parameters:
name- the unique name of the elementattributeSetCollection- the set of attributes to associate with this element
-
-
Method Details
-
getName
- Returns:
- the name of this model element
-
getAttributeSetCollection
- Returns:
- the attribute set collection for this model element
-
setModelElementAccessor
Sets the model element accessor, which provides external access to model context, data, and messaging.This method is protected, as it should only be called during model setup.
- Parameters:
modelElementAccessor- the accessor to associate with this element
-
getModelElementAccessor
- Returns:
- the accessor associated with this element, if initialised
-
setup
public void setup()Initialises the attribute set for this element by calling its setup method. This should be called before the simulation begins. -
run
public abstract void run()Defines the logic to be executed on each simulation tick. Must be implemented by all concrete subclasses (agents and environment).
-