b0ad495cb3a99f439d39ccd1c43bd98e9171fa76
[yazpp-moved-to-github.git] / include / yaz++ / yaz-proxy.h
1 /*
2  * Copyright (c) 1998-2000, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-proxy.h,v 1.4 2001-11-06 17:08:05 adam Exp $
6  */
7
8 #include <yaz++/yaz-z-assoc.h>
9 #include <yaz++/yaz-z-query.h>
10 #include <yaz++/yaz-z-databases.h>
11
12 class Yaz_Proxy;
13
14 /// Private class
15 class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc {
16     friend Yaz_Proxy;
17     Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable);
18     ~Yaz_ProxyClient();
19     void recv_Z_PDU(Z_APDU *apdu);
20     IYaz_PDU_Observer* sessionNotify
21         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
22     void shutdown();
23     Yaz_Proxy *m_server;
24     void failNotify();
25     void timeoutNotify();
26     void connectNotify();
27     char m_cookie[32];
28     Yaz_ProxyClient *m_next;
29     Yaz_ProxyClient **m_prev;
30     int m_init_flag;
31     Yaz_Z_Query *m_last_query;
32     Yaz_Z_Databases m_last_databases;
33     int m_last_resultCount;
34     int m_sr_transform;
35     int m_seqno;
36     int m_waiting;
37 };
38
39 /// Information Retrieval Proxy Server.
40 class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
41  private:
42     char *get_cookie(Z_OtherInformation **otherInfo);
43     char *get_proxy(Z_OtherInformation **otherInfo);
44     Yaz_ProxyClient *get_client(Z_APDU *apdu);
45     Z_APDU *result_set_optimize(Z_APDU *apdu);
46     void shutdown();
47     
48     Yaz_ProxyClient *m_client;
49     IYaz_PDU_Observable *m_PDU_Observable;
50     Yaz_ProxyClient *m_clientPool;
51     Yaz_Proxy *m_parent;
52     int m_seqno;
53     int m_max_clients;
54     int m_keepalive;
55     char *m_proxyTarget;
56     long m_seed;
57     char *m_optimize;
58  public:
59     Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable);
60     ~Yaz_Proxy();
61     void recv_Z_PDU(Z_APDU *apdu);
62     IYaz_PDU_Observer* sessionNotify
63         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
64     void failNotify();
65     void timeoutNotify();
66     void connectNotify();
67     const char *option(const char *name, const char *value);
68     void set_proxyTarget(const char *target);
69     char *get_proxyTarget() { return m_proxyTarget; };
70     void set_max_clients(int m) { m_max_clients = m; };
71 };
72