2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-observer.h,v 1.8 2000-09-08 10:23:42 adam Exp $
8 #ifndef YAZ_PDU_OBSERVER_H
9 #define YAZ_PDU_OBSERVER_H
11 class IYaz_PDU_Observer;
13 /** Protocol Data Unit Observable.
14 This interface implements a Protocol Data Unit (PDU) network driver.
15 The PDU's is not encoded/decoded by this interface. They are simply
16 transmitted/received over the network. To use this interface the
17 IYaz_PDU_Observer interface must be implemented.
19 class YAZ_EXPORT IYaz_PDU_Observable {
21 /// Send encoded PDU buffer of specified length
22 virtual int send_PDU(const char *buf, int len) = 0;
23 /// Connect with server specified by addr.
24 virtual void connect(IYaz_PDU_Observer *observer, const char *addr) = 0;
25 /// Listen on address addr.
26 virtual void listen(IYaz_PDU_Observer *observer, const char *addr) = 0;
28 virtual void close() = 0;
29 /// Make clone of this object using this interface
30 virtual IYaz_PDU_Observable *clone() = 0;
31 /// Destroy completely
32 virtual void destroy() = 0;
34 virtual void idleTime (int timeout) = 0;
35 /// open with existing socket
36 virtual void socket(IYaz_PDU_Observer *observer, int fd) = 0;
39 /** Protocol Data Unit Observer.
40 This interface is used together with the IYaz_PDU_Observable interface
41 and acts as a callback interface for it.
43 class YAZ_EXPORT IYaz_PDU_Observer {
45 /// A PDU has been received
46 virtual void recv_PDU(const char *buf, int len) = 0;
47 /// Called when Iyaz_PDU_Observable::connect was successful.
48 virtual void connectNotify() = 0;
49 /// Called whenever the connection was closed
50 virtual void failNotify() = 0;
51 /// Called whenever there is a timeout
52 virtual void timeoutNotify() = 0;
53 /// Make clone of observer using IYaz_PDU_Observable interface
54 virtual IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable) = 0;