WRBUF updates
[yazpp-moved-to-github.git] / include / yazpp / 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.1 2006-03-29 13:14:15 adam Exp $
6  */
7
8 #ifndef YAZ_PDU_OBSERVER_H
9 #define YAZ_PDU_OBSERVER_H
10
11 #include <yaz/yconfig.h>
12
13 namespace yazpp_1 {
14
15 class IPDU_Observer;
16
17 /** Protocol Data Unit Observable.
18     This interface implements a Protocol Data Unit (PDU) network driver.
19     The PDU's is not encoded/decoded by this interface. They are simply
20     transmitted/received over the network. To use this interface the
21     IPDU_Observer interface must be implemented.
22  */
23 class YAZ_EXPORT IPDU_Observable {
24  public:
25     /// Send encoded PDU buffer of specified length
26     virtual int send_PDU(const char *buf, int len) = 0;
27     /// Connect with server specified by addr.
28     virtual int connect(IPDU_Observer *observer, const char *addr) = 0;
29     /// Listen on address addr.
30     virtual int listen(IPDU_Observer *observer, const char *addr) = 0;
31     /// Close connection
32     virtual void close() = 0;
33     /// Make clone of this object using this interface
34     virtual IPDU_Observable *clone() = 0;
35     /// Destroy completely
36     virtual void destroy() = 0;
37     /// Set Idle Time
38     virtual void idleTime (int timeout) = 0;
39     /// Get peername
40     virtual const char *getpeername() = 0;
41
42     virtual ~IPDU_Observable();
43 };
44
45 /** Protocol Data Unit Observer.
46     This interface is used together with the IPDU_Observable interface
47     and acts as a callback interface for it.
48  */
49 class YAZ_EXPORT IPDU_Observer {
50  public:
51     /// A PDU has been received
52     virtual void recv_PDU(const char *buf, int len) = 0;
53     /// Called when Iyaz_PDU_Observable::connect was successful.
54     virtual void connectNotify() = 0;
55     /// Called whenever the connection was closed
56     virtual void failNotify() = 0;
57     /// Called whenever there is a timeout
58     virtual void timeoutNotify() = 0;
59     /// Make clone of observer using IPDU_Observable interface
60     virtual IPDU_Observer *sessionNotify(
61         IPDU_Observable *the_PDU_Observable, int fd) = 0;
62
63     virtual ~IPDU_Observer();
64 };
65 };
66
67 #endif
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * indent-tabs-mode: nil
72  * End:
73  * vim: shiftwidth=4 tabstop=8 expandtab
74  */
75