More work on timeout handling. Work on yaz-client.
[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  * $Log: yaz-pdu-observer.h,v $
7  * Revision 1.4  1999-03-23 14:17:57  adam
8  * More work on timeout handling. Work on yaz-client.
9  *
10  * Revision 1.3  1999/02/02 14:01:14  adam
11  * First WIN32 port of YAZ++.
12  *
13  * Revision 1.2  1999/01/28 13:08:41  adam
14  * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
15  * yaz-socket-manager.cc.
16  *
17  * Revision 1.1.1.1  1999/01/28 09:41:07  adam
18  * First implementation of YAZ++.
19  *
20  */
21
22 #ifndef YAZ_PDU_OBSERVER_H
23 #define YAZ_PDU_OBSERVER_H
24
25 class IYaz_PDU_Observer;
26
27 /** Protocol Data Unit Observable.
28     This interface implements a Protocol Data Unit (PDU) network driver.
29     The PDU's is not encoded/decoded by this interface. They are simply
30     transmitted/received over the network. To use this interface the
31     IYaz_PDU_Observer interface must be implemented.
32  */
33 class YAZ_EXPORT IYaz_PDU_Observable {
34  public:
35     /// Send encoded PDU buffer of specified length
36     virtual int send_PDU(const char *buf, int len) = 0;
37     /// Connect with server specified by addr.
38     virtual void connect(IYaz_PDU_Observer *observer, const char *addr) = 0;
39     /// Listen on address addr.
40     virtual void listen(IYaz_PDU_Observer *observer, const char *addr) = 0;
41     /// Close connection
42     virtual void close() = 0;
43     /// Make clone of this object using this interface
44     virtual IYaz_PDU_Observable *clone() = 0;
45     /// Destroy completely
46     virtual void destroy() = 0;
47     /// Set Idle Time
48     virtual void idleTime (int timeout) = 0;
49 };
50
51 /** Protocol Data Unit Observer.
52     This interface is used together with the IYaz_PDU_Observable interface
53     and acts as a callback interface for it.
54  */
55 class YAZ_EXPORT IYaz_PDU_Observer {
56  public:
57     /// A PDU has been received
58     virtual void recv_PDU(const char *buf, int len) = 0;
59     /// Called when Iyaz_PDU_Observabvle::connect was successful.
60     virtual void connectNotify() = 0;
61     /// Called whenever the connection was closed
62     virtual void failNotify() = 0;
63     /// Called whenever the connection was closed
64     virtual void timeoutNotify() = 0;
65     /// Make clone of observer using IYaz_PDU_Observable interface
66     virtual IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable) = 0;
67 };
68
69 #endif