001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2007 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.core.agent;
028:
029: import java.util.List;
030: import java.util.Map;
031: import java.util.Set;
032:
033: import org.cougaar.core.component.ComponentDescription;
034: import org.cougaar.core.component.StateTuple;
035: import org.cougaar.core.mts.MessageAddress;
036:
037: /**
038: * The AgentContainer manages all agents on the node.
039: */
040: public interface AgentContainer {
041:
042: /**
043: * Equivalent to
044: * <code>(getAgentDescription(agentId) != null)</code>
045: *
046: * @return true if the agent is on the local node
047: */
048: boolean containsAgent(MessageAddress agentId);
049:
050: /**
051: * Equivalent to
052: * <code>getLocalAgentDescriptions().keySet()</code>
053: *
054: * @return a Set of all local agent MessageAddresses
055: */
056: Set getAgentAddresses();
057:
058: /**
059: * Equivalent to
060: * <code>getLocalAgentDescriptions().get(agentId)</code>
061: *
062: * @return null if the agent is not on the local node,
063: * or the description is not known.
064: */
065: ComponentDescription getAgentDescription(MessageAddress agentId);
066:
067: /**
068: * Get an unmodifiable map of local agent MessageAddress to the
069: * ComponentDescriptions.
070: *
071: * @return a Map<MessageAddress><ComponentDescriptions>
072: * for the local agents
073: */
074: Map getAgents();
075:
076: List getComponents();
077:
078: /**
079: * Add a new agent to the local node.
080: */
081: void addAgent(MessageAddress agentId);
082:
083: /**
084: * <i>deprecated</i>, use one of the above "addAgent" method.
085: */
086: void addAgent(MessageAddress agentId, StateTuple tuple);
087:
088: /**
089: * Add a component to this agent container. Only certain components
090: * are allowed using this method. In particular, agents cannot be
091: * added.
092: */
093: boolean add(Object o);
094:
095: /**
096: * Remove an agent that's on the local node.
097: *
098: * @throws RuntimeException if the agent is not on the
099: * local node, or it can't be removed.
100: */
101: void removeAgent(MessageAddress agentId);
102:
103: /**
104: * Remove component from this agent container. Only components added
105: * with the add method can be removed this way. Agents cannot be
106: * removed with this method.
107: */
108: boolean remove(Object o);
109: }
|