mil.navy.nps.relate
Class RelationshipManager

java.lang.Object
  extended bymil.navy.nps.relate.RelationshipManager

public class RelationshipManager
extends java.lang.Object

RelationshipManager is the heart of the RELATE simulation package.

RelationshipManager is an example of the "singleton" programming pattern. "Singleton" means that there is one, and only one, instance of this class per application. This is accomplished by the static, synchronized getRelationshipManager() method. This method creates a new RelationshipManager upon the first request, or returns the existing, unique RelationshipManager if it has already been created. The RelationshipManager is the only complete Java class in RELATE. All other classes are either abstract or interfaces. An abstract class contains one or more abstract methods that are required to be defined by the developer. An interface has no data members and all methods must be defined by the developer.

The RelationshipManager handles the formation and administration of all relationships by requiring agents to form relationships with the checkForRelationships() method. This method is the most significant method in this class. It checks for every possible relationship that can be formed between the requesting, passed in agent and other agents in its sensedEnvironment. Since the requirements for formation of new relationships are defined within the individual relationships, the RelationshipManager instantiates the requested relationship using the createRelationship() method. This is possible due to the no-argument constructor used in the Relationship interface. If conditions are met, it adds the agent to this new Relationship. Otherwise, the relationship is never utilized and it is cleaned up with the automatic garbage collection feature of Java. Relationship administration is accomplished by maintaining a current list, or vector, of active relationships, available through a getter method. The RelationshipManager adds relationships to this vector, but they are removed by the individual relationships.

See the Relationship class for more details on how relationships interact with the RelationshipManager.

Since:
JDK1.3
Version:
1.0, 17 Aug 00
Author:
Michael R. Dickson, Kimberly A. Roddy

Field Summary
 java.util.Vector activeRelationshipVec
          Contains all currently active relationships in the simulation.
 java.util.Hashtable agentTable
          Contains all agents that have made the checkForRelationships() call.
 
Method Summary
 void addAgent(Agent pAgent)
          Adds the passed in agent to the agentTable Hashtable.
 void checkForRelationships(Agent pAgent)
          Checks for all possible relationships between the passed in agent and all of the agent's sensed agents.
 java.util.Vector getFormedRelationships()
          Simple getter method for getting the active relationship vector.
static RelationshipManager getRelationshipManager()
          Method that returns the singleton relationshipManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeRelationshipVec

public java.util.Vector activeRelationshipVec
Contains all currently active relationships in the simulation.


agentTable

public java.util.Hashtable agentTable
Contains all agents that have made the checkForRelationships() call.

Method Detail

getRelationshipManager

public static RelationshipManager getRelationshipManager()
Method that returns the singleton relationshipManager.


addAgent

public void addAgent(Agent pAgent)
Adds the passed in agent to the agentTable Hashtable.


checkForRelationships

public void checkForRelationships(Agent pAgent)
Checks for all possible relationships between the passed in agent and all of the agent's sensed agents. If the agent can join a perviously formed relationship, it is added and further checking for that relationship is stopped. If no perviously formed relationships can be joined, a new relationship is formed and tested to see if its conditions are met with the agent and all sensed agents that are not currently in that realtionship. If they are, then the relationship is added to the active realtionship vector and the agents are issued roles/goals/rules from the new relationship. If conditions are not met the relationship is destroyed and the agent does not join a relationship.


getFormedRelationships

public java.util.Vector getFormedRelationships()
Simple getter method for getting the active relationship vector.