dfe25968e2781552f14138f9b51bd95d1a6c71bf
[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.2 2008-01-21 15:57:27 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 shutdown() = 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     /// Close session
42     virtual void close_session() = 0;
43
44     virtual ~IPDU_Observable();
45 };
46
47 /** Protocol Data Unit Observer.
48     This interface is used together with the IPDU_Observable interface
49     and acts as a callback interface for it.
50  */
51 class YAZ_EXPORT IPDU_Observer {
52  public:
53     /// A PDU has been received
54     virtual void recv_PDU(const char *buf, int len) = 0;
55     /// Called when Iyaz_PDU_Observable::connect was successful.
56     virtual void connectNotify() = 0;
57     /// Called whenever the connection was closed
58     virtual void failNotify() = 0;
59     /// Called whenever there is a timeout
60     virtual void timeoutNotify() = 0;
61     /// Make clone of observer using IPDU_Observable interface
62     virtual IPDU_Observer *sessionNotify(
63         IPDU_Observable *the_PDU_Observable, int fd) = 0;
64
65     virtual ~IPDU_Observer();
66 };
67 };
68
69 #endif
70 /*
71  * Local variables:
72  * c-basic-offset: 4
73  * indent-tabs-mode: nil
74  * End:
75  * vim: shiftwidth=4 tabstop=8 expandtab
76  */
77