com.agentfactory.cldc.logic
Class RoleLibrary

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

public class RoleLibrary
extends java.lang.Object

The role library contains the role templates that the agent will instantiate under various circumstances. In AFME, each agent may have several role templates. Additionally, each template may have several instances. The role library contains and manages the hash table of role templates and the hash table of role instances.

Author:
Conor Muldoon

Constructor Summary
RoleLibrary()
          Creates a new instance of RoleLibrary.
 
Method Summary
 void add(FOS identifier, RoleTemplate rt)
          Adds a role template to the role template table using the functor of the specified identifier as the key.
 void append(java.lang.StringBuffer buffer)
          Appends the role instances to the specified buffer.
 void deactivateRole(FOS fos)
          Deactivates the role that has the specified identifier.
 void enactRole(FOS identifier, Agent agent)
          If there is not already a role instance with the specified identifier, creates a role instance using the appropriate template.
 void solve(Agent agent)
          Processes the triggers of each of the role templates and executes each of the role instances.
 void writeToStream(java.io.DataOutputStream output)
          Writes each of the role templates to the the speicifed data output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoleLibrary

public RoleLibrary()
Creates a new instance of RoleLibrary.

Method Detail

add

public void add(FOS identifier,
                RoleTemplate rt)
Adds a role template to the role template table using the functor of the specified identifier as the key.

Parameters:
identifier - the identifier for the template.
rt - the role template to be added to the role template table.

enactRole

public void enactRole(FOS identifier,
                      Agent agent)
               throws MalformedLogicException
If there is not already a role instance with the specified identifier, creates a role instance using the appropriate template.

Parameters:
identifier - the identifier for the role.
agent - the agent that adopts the role.
Throws:
MalformedLogicException - if there is a logic error.

deactivateRole

public void deactivateRole(FOS fos)
Deactivates the role that has the specified identifier.

Parameters:
fos - the identifier of the role that is to be deactivated.

writeToStream

public void writeToStream(java.io.DataOutputStream output)
                   throws java.io.IOException
Writes each of the role templates to the the speicifed data output stream.

Parameters:
output - the stream that the templates are written to.
Throws:
java.io.IOException - if there is an I/O error.

solve

public void solve(Agent agent)
           throws MalformedLogicException
Processes the triggers of each of the role templates and executes each of the role instances.

Parameters:
agent - the agent that the role library belongs to.
Throws:
MalformedLogicException - if there is a logic error.

append

public void append(java.lang.StringBuffer buffer)
Appends the role instances to the specified buffer.

Parameters:
buffer - the string buffer that role instances are appended to.