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