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