Moved header files to include/yaz++. Switched to libtool and automake.
[yazpp-moved-to-github.git] / include / yaz++ / yaz-pdu-observer.h
1 /*
2  * Copyright (c) 1998-2000, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-pdu-observer.h,v 1.1 2000-10-11 11:58:16 adam Exp $
6  */
7
8 #ifndef YAZ_PDU_OBSERVER_H
9 #define YAZ_PDU_OBSERVER_H
10
11 class IYaz_PDU_Observer;
12
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.
18  */
19 class YAZ_EXPORT IYaz_PDU_Observable {
20  public:
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;
27     /// Close connection
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;
33     /// Set Idle Time
34     virtual void idleTime (int timeout) = 0;
35     /// open with existing socket
36     virtual void socket(IYaz_PDU_Observer *observer, int fd) = 0;
37 };
38
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.
42  */
43 class YAZ_EXPORT IYaz_PDU_Observer {
44  public:
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;
55 };
56
57 #endif