mil.navy.nps.relate
Interface Relationship

All Known Implementing Classes:
RelationshipBlueSquad, RelationshipRedSquad

public interface Relationship

Relationships are the life-blood of the RELATE architecture.

One of the most important aspects of a Java class that implements the Relationship interface is that it must have a no-argument constructor. As described above, this allows the RelationshipManager to create it dynamically to verify prerequisites and assign members. Relationships have a conditionsMaintained() method that is used by the RelationshipManager to verify prerequisites are met prior to creating the relationship. Once created by the RelationshipManager, the Relationship objects are independent agents that issue roles to each member agent using the issueRoles() method. They also monitor conditions of, their members. They also destroy themselves if minimum requirements for existence are not maintained using the method destroyRelationship(). When this happens, the relationship withdrawals all of its associated Role objects from each member, then removes itself from the RelationshipManager's active relationship vector.

See the RelationshipManager 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

Method Summary
 boolean addAgent(Agent pAgent)
          Adds the passed in agent to the list of members of this relationship.
 boolean conditionsMaintained()
          Verifies conditions are maintained to continue this relationship.
 boolean conditionsMet(Agent pAgent, java.util.Vector pSensedAgents)
          Verifies conditions are met to form this relationship.
 void destroyRelationship()
          When conditions are no longer met to maintain this relationship, this method is called.
 java.lang.String getClassName()
          Returns The class name of this relationship.
 int getIDNumber()
          Returns the ID number of this relationship.
 java.util.Vector getMembers()
          Returns the vector of members currently in this relationship
 void issueRoles()
          Issues the appropriate roles to each member in the relationship.
 boolean removeAgent(Agent pAgent)
          Removes the passed in agent from the list of members of this relationship.
 void setClassName(java.lang.String pClassName)
          Sets the class name of this relationship
 void setIDNumber(int pID)
          Sets the ID number of this relationship
 java.lang.String toString()
          Returns a formated description of this relationship suitable for printing
 

Method Detail

conditionsMet

public boolean conditionsMet(Agent pAgent,
                             java.util.Vector pSensedAgents)
Verifies conditions are met to form this relationship. If conditions are met, this method adds the accepted agents to the members Vector. This allows the relationshipManager to assign membership to this relationship to the agents relationship Hashtable.

Parameters:
pAgent - The agent attempting to form the relationship
pSensedAgents - A vector containing all of the sensed agents
Returns:
The success of verifying conditions are met and addition of agents to the members vector.
  • true - Conditions are met
  • false - Conditions are not met

  • conditionsMaintained

    public boolean conditionsMaintained()
    Verifies conditions are maintained to continue this relationship.

    Returns:
    The success of verifying conditions are maintained:
  • true - Conditions are maintained
  • false - Conditions are not maintained

  • destroyRelationship

    public void destroyRelationship()
    When conditions are no longer met to maintain this relationship, this method is called. It removes all reference to itself from agents in its members list as well as the RelationshipManager


    issueRoles

    public void issueRoles()
    Issues the appropriate roles to each member in the relationship.


    addAgent

    public boolean addAgent(Agent pAgent)
    Adds the passed in agent to the list of members of this relationship.

    Parameters:
    pAgent - The agent to be added to this relationship.
    Returns:
    The success of adding the agent:
  • true - pAgent is added
  • false - pAgent was not added

  • removeAgent

    public boolean removeAgent(Agent pAgent)
    Removes the passed in agent from the list of members of this relationship.

    Parameters:
    pAgent - The agent to be removed from this relationship.
    Returns:
    The success of removing the agent:
  • true - pAgent is removed
  • false - pAgent was not removed

  • getIDNumber

    public int getIDNumber()
    Returns the ID number of this relationship.

    Returns:
    ID number

    setIDNumber

    public void setIDNumber(int pID)
    Sets the ID number of this relationship

    Parameters:
    pID - The new ID number

    setClassName

    public void setClassName(java.lang.String pClassName)
    Sets the class name of this relationship

    Parameters:
    pClassName - The new class name

    getClassName

    public java.lang.String getClassName()
    Returns The class name of this relationship.

    Returns:
    Class name

    getMembers

    public java.util.Vector getMembers()
    Returns the vector of members currently in this relationship

    Returns:
    members

    toString

    public java.lang.String toString()
    Returns a formated description of this relationship suitable for printing

    Returns:
    Relationship string description