2 * Copyright (c) 1998-2005, Index Data.
3 * See the file LICENSE for details.
5 * $Id: socket-observer.h,v 1.1 2006-03-29 13:14:15 adam Exp $
8 #ifndef YAZ_SOCKET_OBSERVER_H
9 #define YAZ_SOCKET_OBSERVER_H
11 #include <yaz/yconfig.h>
16 SOCKET_OBSERVE_READ=1,
17 SOCKET_OBSERVE_WRITE=2,
18 SOCKET_OBSERVE_EXCEPT=4,
19 SOCKET_OBSERVE_TIMEOUT=8
25 class ISocketObserver;
27 /** Socket Observable.
28 This interface implements notification of socket events.
29 The module interested in (observing) the sockets
30 must implement the ISocketObserver interface. The
31 ISocketObserver only have to implement one function, so it's
32 quite simple to observe sockets change state.
33 The socket events below specifies read, write, exception,
34 and timeout respectively:
39 SOCKET_OBSERVE_TIMEOUT
41 The maskObserver method specifies which of these events the
42 observer is intertested in.
44 class YAZ_EXPORT ISocketObservable {
46 /// Add an observer interested in socket fd
47 virtual void addObserver(int fd, ISocketObserver *observer) = 0;
48 /// Delete an observer
49 virtual void deleteObserver(ISocketObserver *observer) = 0;
50 /// Delete all observers
51 virtual void deleteObservers() = 0;
52 /// Specify the events that the observer is intersted in.
53 virtual void maskObserver(ISocketObserver *observer, int mask) = 0;
55 virtual void timeoutObserver(ISocketObserver *observer,
57 virtual ~ISocketObservable();
61 The ISocketObserver interface implements a module interested
62 socket events. Look for objects that implements the
63 ISocketObservable interface!
65 class YAZ_EXPORT ISocketObserver {
67 /// Notify the observer that something happened to socket
68 virtual void socketNotify(int event) = 0;
69 virtual ~ISocketObserver();
77 * indent-tabs-mode: nil
79 * vim: shiftwidth=4 tabstop=8 expandtab