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