com.agentfactory.cldc.logic
Class RoleTemplate

java.lang.Object
  extended by com.agentfactory.cldc.logic.RoleTemplate

public class RoleTemplate
extends java.lang.Object

In AFME, support is provided for AFAPL2 roles. A role represents abstract behaviour patterns that agents adopt at various stages of execution. The processing overhead of roles is only incurred when the agents adopt the roles. This improves the efficiency of the reasoning process. Role templates represent schemas that agents can adopt. Variable within the identifier of the role template are applied to create a particular role instance when the role has been triggered or activated. If there are no variables in the identifier, then the role instance is just created directly. See the Agent Factory and AFME documentation for more information.

Author:
Conor Muldoon

Constructor Summary
RoleTemplate(TerImplication[] rule, FOS identifier, FOS[] trig)
          Creates a new instance of RoleTemplate.
 
Method Summary
 void createInstance(SubstitutionSet binding, java.util.Hashtable table)
          Applies the specified substituion set to the identifier for the role template.
 void instantiate(FOS identifier, java.util.Hashtable table)
          If the specifed identifier matches the identifier for the role template, an instance of the role is created provided a role that has the specified identifier does not already exist.
 void processTrigger(Agent agent, java.util.Hashtable table)
          Checks whether the role template has been triggered.
 void writeToStream(java.io.DataOutputStream output)
          Writes the state of the role template to a data output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoleTemplate

public RoleTemplate(TerImplication[] rule,
                    FOS identifier,
                    FOS[] trig)
Creates a new instance of RoleTemplate.

Parameters:
rule - an array of commitment rules.
identifier - a first order structure that is used to identify the role.
trig - the triggers for the role.
Method Detail

writeToStream

public void writeToStream(java.io.DataOutputStream output)
                   throws java.io.IOException
Writes the state of the role template to a data output stream.

Parameters:
output - the data output stream the state is to be written to.
Throws:
java.io.IOException - if there is an I/O error.

instantiate

public void instantiate(FOS identifier,
                        java.util.Hashtable table)
                 throws MalformedLogicException
If the specifed identifier matches the identifier for the role template, an instance of the role is created provided a role that has the specified identifier does not already exist. The specified hash table represents a mapping between role instances and identifiers. Once a role instance is created by applying the specified identifier to the template commitment rules, it is added to the hashtable of instances.

Parameters:
identifier - the identifier of the role instance to be created.
table - the hash table of role instances.
Throws:
MalformedLogicException - if there is a logic error.

createInstance

public void createInstance(SubstitutionSet binding,
                           java.util.Hashtable table)
                    throws MalformedLogicException
Applies the specified substituion set to the identifier for the role template. If the constucted first order structure is not the identifier for a role instance, a role instance is created using the first order structure and added to the specified hash table.

Parameters:
binding - the substitution set that is applied to the template identifier.
table - the hash table of role instances.
Throws:
MalformedLogicException - if there is a logic error.

processTrigger

public void processTrigger(Agent agent,
                           java.util.Hashtable table)
                    throws MalformedLogicException
Checks whether the role template has been triggered. If the template has been triggered, a new role instance is created and added to the hash table provided a instance with the same identifier is not currently active.

Parameters:
agent - the agent that the role template belongs to.
table - the hashtable of role instances.
Throws:
MalformedLogicException - if there is a logic error.