lij.runtime
Class DefInstance

java.lang.Object
  extended by lij.runtime.DefInstance
Direct Known Subclasses:
DefInstance.DefAgentInstance, DefInstance.DefMessageInstance, DefInstance.DefNullOpInstance

public abstract class DefInstance
extends java.lang.Object

This class executes Def's. It's main purpose is to decouple the execution code from the model.Def class

Author:
Nikolaos Chatzinikolaou

Nested Class Summary
private static class DefInstance.DefAgentInstance
          A DefInstance subclass for AGENT (i.e.
private static class DefInstance.DefMessageInstance
          A DefInstance subclass for MESSAGE (i.e.
private static class DefInstance.DefNullOpInstance
          A DefInstance subclass for NULLOP events.
 
Field Summary
protected  AgentInstance agent
           
protected  Def def
           
protected  Interpreter interpreter
           
 
Constructor Summary
DefInstance()
           
 
Method Summary
private  Result.State checkConstraints()
          Checks the constraints of this DefInstance.
static DefInstance createDefInstance(Def _def, Interpreter _interpreter, AgentInstance _agent)
          Factory method for creating an instance of a DefInstance subclass.
 Result.State execute()
          Executes this DefInstance.
abstract  Result.State executeEvent()
          This method needs to be implemented by any subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

def

protected Def def

interpreter

protected Interpreter interpreter

agent

protected AgentInstance agent
Constructor Detail

DefInstance

public DefInstance()
Method Detail

createDefInstance

public static DefInstance createDefInstance(Def _def,
                                            Interpreter _interpreter,
                                            AgentInstance _agent)
Factory method for creating an instance of a DefInstance subclass.

Parameters:
_def - The Def that will be encapsulated by this DefInstance object.
_interpreter - A reference to the currently running Interpreter instance.
_agent - The AgentInstance performing the instantiation.
Returns:
The instantiated DefInstance.

execute

public Result.State execute()
                     throws InterpreterException
Executes this DefInstance. This includes checking the list of Constraints associated with this Def. The execution of the actual event will be delegated to the subclasses, via the executeEvent() method.

Returns:
The result of the execution (TRUE, FALSE or MAYBE).
Throws:
InterpreterException

checkConstraints

private Result.State checkConstraints()
                               throws InterpreterException
Checks the constraints of this DefInstance.

Returns:
The result of the check (TRUE, FALSE or MAYBE).
Throws:
InterpreterException

executeEvent

public abstract Result.State executeEvent()
                                   throws InterpreterException
This method needs to be implemented by any subclasses. It performs the execution of the actual event associated with this Def.

Returns:
The result of the execution (TRUE, FALSE or MAYBE).
Throws:
InterpreterException