1
2
3
4
5
6
7 package nl.tudelft.simulation.event;
8
9 import java.rmi.RemoteException;
10
11 /***
12 * The EventProducerInterface defines the registration operations of an
13 * eventproducer. This behavior includes adding and removing listeners for a
14 * specific event type.
15 * <p>
16 * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
17 * University of Technology </a>, the Netherlands.
18 * <p>
19 * See for project information <a
20 * href="http://www.simulation.tudelft.nl/dsol/event">www.simulation.tudelft.nl/event
21 * </a> <br>
22 * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
23 * General Public License (LGPL) </a>, no warranty
24 *
25 * @author <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
26 * @version $Revision: 1.5 $ $Date: 2005/07/04 12:23:01 $
27 * @since 1.5
28 */
29 public interface EventProducerInterface
30 {
31 /*** The FIRST_POSITION in the queue */
32 short FIRST_POSITION = 0;
33
34 /*** The LAST_POSITION in the queue */
35 short LAST_POSITION = -1;
36
37 /***
38 * adds a listener as strong reference to the BEGINNING of a queue of
39 * listeners.
40 *
41 * @param listener the listener which is interested at events of eventtype.
42 * @param eventType the events of interest.
43 * @return the success of adding the listener. If a listener was already
44 * added false is returned.
45 * @throws RemoteException If a network connection failure occurs.
46 * @see nl.tudelft.simulation.event.ref.WeakReference
47 */
48 boolean addListener(EventListenerInterface listener, EventType eventType)
49 throws RemoteException;
50
51 /***
52 * adds a listener to the BEGINNING of a queue of listeners.
53 *
54 * @param listener the listener which is interested at events of eventtype.
55 * @param eventType the events of interest.
56 * @param weak whether or not the listener is added as weak reference.
57 * @return the success of adding the listener. If a listener was already
58 * added false is returned.
59 * @throws RemoteException If a network connection failure occurs.
60 * @see nl.tudelft.simulation.event.ref.WeakReference
61 */
62 boolean addListener(EventListenerInterface listener, EventType eventType,
63 boolean weak) throws RemoteException;
64
65 /***
66 * adds a listener as strong reference to the specified position of a queue
67 * of listeners.
68 *
69 * @param listener the listener which is interested at events of eventtype.
70 * @param eventType the events of interest.
71 * @param position the position of the listener in the queue.
72 * @return the success of adding the listener. If a listener was already
73 * added, or an illegal position is provided false is returned.
74 * @throws RemoteException If a network connection failure occurs.
75 * @see nl.tudelft.simulation.event.ref.WeakReference
76 */
77 boolean addListener(EventListenerInterface listener, EventType eventType,
78 short position) throws RemoteException;
79
80 /***
81 * adds a listener to the specified position of a queue of listeners.
82 *
83 * @param listener which is interested at certain events,
84 * @param eventType the events of interest.
85 * @param position the position of the listener in the queue
86 * @param weak whether the reference should be weak or strong.
87 * @return the success of adding the listener. If a listener was already
88 * added or an illegal position is provided false is returned.
89 * @throws RemoteException If a network connection failure occurs.
90 */
91 boolean addListener(EventListenerInterface listener, EventType eventType,
92 short position, boolean weak) throws RemoteException;
93
94 /***
95 * returns all the eventTypes for which a listener can subscribe.
96 *
97 * @return EventType[] returns the eventTypes for which listeners can
98 * subscribe.
99 * @throws RemoteException If a network connection failure occurs.
100 */
101 EventType[] getEventTypes() throws RemoteException;
102
103 /***
104 * removes the subscription of a listener for a specific event.
105 *
106 * @param listener which is no longer interested.
107 * @param eventType the event which is of no interest any more.
108 * @return the success of removing the listener. If a listener was not
109 * subscribed false is returned.
110 * @throws RemoteException If a network connection failure occurs.
111 */
112 boolean removeListener(EventListenerInterface listener, EventType eventType)
113 throws RemoteException;
114 }