Moved header files to include/yaz++. Switched to libtool and automake.
[yazpp-moved-to-github.git] / include / yaz++ / yaz-socket-observer.h
1 /*
2  * Copyright (c) 1998-2000, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-socket-observer.h,v 1.1 2000-10-11 11:58:16 adam Exp $
6  */
7
8 #ifndef YAZ_SOCKET_OBSERVER_H
9 #define YAZ_SOCKET_OBSERVER_H
10
11 #define YAZ_SOCKET_OBSERVE_READ 1
12 #define YAZ_SOCKET_OBSERVE_WRITE 2
13 #define YAZ_SOCKET_OBSERVE_EXCEPT 4
14 #define YAZ_SOCKET_OBSERVE_TIMEOUT 8
15
16 /**
17    Forward reference
18  */
19 class IYazSocketObserver;
20
21 /** Socket Observable.
22    This interface implements notification of socket events.
23    The module interested in (observing) the sockets
24    must implement the IYazSocketObserver interface. The
25    IYazSocketObserver only have to implement one function, so it's
26    quite simple to observe sockets change state.
27    The socket events below specifies read, write, exception,
28    and timeout respectively:
29    <pre>
30     YAZ_SOCKET_OBSERVE_READ
31     YAZ_SOCKET_OBSERVE_WRITE
32     YAZ_SOCKET_OBSERVE_EXCEPT
33     YAZ_SOCKET_OBSERVE_TIMEOUT
34     </pre>
35     The maskObserver method specifies which of these events the
36     observer is intertested in.
37 */
38 class YAZ_EXPORT IYazSocketObservable {
39  public:
40     /// Add an observer interested in socket fd
41     virtual void addObserver(int fd, IYazSocketObserver *observer) = 0;
42     /// Delete an observer
43     virtual void deleteObserver(IYazSocketObserver *observer) = 0;
44     /// Delete all observers
45     virtual void deleteObservers() = 0;
46     /// Specify the events that the observer is intersted in.
47     virtual void maskObserver(IYazSocketObserver *observer, int mask) = 0;
48     /// Specify timeout
49     virtual void timeoutObserver(IYazSocketObserver *observer,
50                                  unsigned timeout)=0;
51 };
52
53 /** Socket Observer.
54    The IYazSocketObserver interface implements a module interested
55    socket events. Look for objects that implements the
56    IYazSocketObservable interface!
57 */
58 class YAZ_EXPORT IYazSocketObserver {
59  public:
60     /// Notify the observer that something happened to socket
61     virtual void socketNotify(int event) = 0;
62 };
63
64 #endif