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