Modified for new location of YAZ header files. Experimental threaded
[yazpp-moved-to-github.git] / include / yaz-pdu-observer.h
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  * 
6  * $Id: yaz-pdu-observer.h,v 1.7 1999-12-06 13:52:45 adam Exp $
7  */
8
9 #ifndef YAZ_PDU_OBSERVER_H
10 #define YAZ_PDU_OBSERVER_H
11
12 class IYaz_PDU_Observer;
13
14 /** Protocol Data Unit Observable.
15     This interface implements a Protocol Data Unit (PDU) network driver.
16     The PDU's is not encoded/decoded by this interface. They are simply
17     transmitted/received over the network. To use this interface the
18     IYaz_PDU_Observer interface must be implemented.
19  */
20 class YAZ_EXPORT IYaz_PDU_Observable {
21  public:
22     /// Send encoded PDU buffer of specified length
23     virtual int send_PDU(const char *buf, int len) = 0;
24     /// Connect with server specified by addr.
25     virtual void connect(IYaz_PDU_Observer *observer, const char *addr) = 0;
26     /// Listen on address addr.
27     virtual void listen(IYaz_PDU_Observer *observer, const char *addr) = 0;
28     /// Close connection
29     virtual void close() = 0;
30     /// Make clone of this object using this interface
31     virtual IYaz_PDU_Observable *clone() = 0;
32     /// Destroy completely
33     virtual void destroy() = 0;
34     /// Set Idle Time
35     virtual void idleTime (int timeout) = 0;
36     /// open with existing socket
37     virtual void socket(IYaz_PDU_Observer *observer, int fd) = 0;
38 };
39
40 /** Protocol Data Unit Observer.
41     This interface is used together with the IYaz_PDU_Observable interface
42     and acts as a callback interface for it.
43  */
44 class YAZ_EXPORT IYaz_PDU_Observer {
45  public:
46     /// A PDU has been received
47     virtual void recv_PDU(const char *buf, int len) = 0;
48     /// Called when Iyaz_PDU_Observable::connect was successful.
49     virtual void connectNotify() = 0;
50     /// Called whenever the connection was closed
51     virtual void failNotify() = 0;
52     /// Called whenever there is a timeout
53     virtual void timeoutNotify() = 0;
54     /// Make clone of observer using IYaz_PDU_Observable interface
55     virtual IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable) = 0;
56 };
57
58 #endif