001: /*
002: * <copyright>
003: *
004: * Copyright 2003-2004 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.service;
028:
029: import java.util.Set;
030:
031: import org.cougaar.core.adaptivity.OperatingMode;
032: import org.cougaar.core.component.Service;
033: import org.cougaar.core.persist.NotPersistable;
034:
035: /**
036: * This service is used by the {@link
037: * org.cougaar.core.adaptivity.AdaptivityEngine} to find
038: * {@link OperatingMode}s on the blackboard.
039: */
040: public interface OperatingModeService extends Service {
041: /**
042: * The interface to be implemented by listeners to this service.
043: * Listeners are publishChanged when the state of operating modes
044: * changes according to the options expressed by the listener.
045: */
046: interface Listener extends NotPersistable {
047: /**
048: * Are additions wanted.
049: * @return true if the listener is interested in additions of new
050: * OperatingModes.
051: */
052: boolean wantAdds();
053:
054: /**
055: * Are changes wanted.
056: * @return true if the listener is interested in changes to
057: * existing OperatingModes.
058: */
059: boolean wantChanges();
060:
061: /**
062: * Are removes wanted.
063: * @return true if the listener is interested in removal of
064: * existing OperatingModes.
065: */
066: boolean wantRemoves();
067: }
068:
069: class ListenerAdapter {
070: public boolean wantAdds() {
071: return false;
072: }
073:
074: public boolean wantChanges() {
075: return false;
076: }
077:
078: public boolean wantRemoves() {
079: return false;
080: }
081: }
082:
083: /**
084: * Add a listener to this service. Listeners are publishChanged
085: * according to their interest when the status of operating modes
086: * changes.
087: * @param l the listener to add
088: */
089: void addListener(Listener l);
090:
091: /**
092: * Remove a listener to this service. Removed listeners will no
093: * longer be publishChanged.
094: * @param l the listener to remove
095: */
096: void removeListener(Listener l);
097:
098: /**
099: * Get an OperatingMode object by name.
100: */
101: OperatingMode getOperatingModeByName(String knobName);
102:
103: /**
104: * Get the names of all known SensorMeasurements.
105: */
106: Set getAllOperatingModeNames();
107: }
|