|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmil.navy.nps.relate.RelationshipManager
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.
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 |
public java.util.Vector activeRelationshipVec
public java.util.Hashtable agentTable
Method Detail |
public static RelationshipManager getRelationshipManager()
public void addAgent(Agent pAgent)
public void checkForRelationships(Agent pAgent)
public java.util.Vector getFormedRelationships()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |