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