3f399c17772789e4330fe7081771322057bf1671
[yazpp-moved-to-github.git] / include / yaz++ / yaz-z-server.h
1 /*
2  * Copyright (c) 2000-2001, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-z-server.h,v 1.6 2001-04-04 14:02:49 adam Exp $
6  */
7
8 #include <yaz++/yaz-z-assoc.h>
9 #include <yaz/zes-ursula.h>
10
11 class Yaz_Z_Server;
12
13 class YAZ_EXPORT Yaz_Z_ServerUtility {
14  public:
15     void create_databaseRecord (ODR odr, Z_NamePlusRecord *rec,
16                                 const char *dbname, int format,
17                                 const void *buf, int len);
18     void create_surrogateDiagnostics(ODR odr, Z_NamePlusRecord *rec,
19                                      const char *dbname, int error,
20                                      char *const addinfo);
21     
22     Z_Records *create_nonSurrogateDiagnostics (ODR odr, int error,
23                                                const char *addinfo);
24 };
25
26 class YAZ_EXPORT IYaz_Server_Facility {
27  public:
28     virtual int init(Yaz_Z_Server *server,
29                      Z_InitRequest *initRequest,
30                      Z_InitResponse *initResponse) = 0;
31     virtual int recv(Yaz_Z_Server *server, Z_APDU *apdu) = 0;
32 };
33
34
35 class YAZ_EXPORT Yaz_Facility_Ursula : public IYaz_Server_Facility {
36  public:
37     virtual void ursula_service (Z_ExtendedServicesRequest *req,
38                                  Z_UrsPDU *u,
39                                  Z_ExtendedServicesResponse *res) = 0;
40
41     int init(Yaz_Z_Server *server,
42              Z_InitRequest *initRequest,
43              Z_InitResponse *initResponse);
44     int recv(Yaz_Z_Server *server, Z_APDU *apdu);
45 };
46
47
48 class YAZ_EXPORT Yaz_Facility_ILL : public IYaz_Server_Facility {
49  public:
50     virtual int ill_init (Z_InitRequest *initRequest,
51                           Z_InitResponse *initResponse) = 0;
52
53     virtual void ill_service (Z_ExtendedServicesRequest *req,
54                               Z_ItemOrder *io,
55                               Z_ExtendedServicesResponse *res) = 0;
56
57     int init(Yaz_Z_Server *server,
58              Z_InitRequest *initRequest,
59              Z_InitResponse *initResponse);
60     int recv(Yaz_Z_Server *server, Z_APDU *apdu);
61 };
62
63 class YAZ_EXPORT Yaz_Facility_Retrieval : public IYaz_Server_Facility,
64     public Yaz_Z_ServerUtility {
65  public:
66
67     virtual int sr_init (Z_InitRequest *initRequest,
68                          Z_InitResponse *initResponse) = 0;
69     virtual void sr_search (Z_SearchRequest *searchRequest,
70                             Z_SearchResponse *searchResponse) = 0;
71     virtual void sr_present (Z_PresentRequest *presentRequest,
72                              Z_PresentResponse *presentResponse) = 0;
73     virtual void sr_record (const char *resultSetName,
74                             int position,
75                             int *format,
76                                 Z_RecordComposition *comp,
77                                 Z_NamePlusRecord *namePlusRecord,
78                                 Z_Records *diagnostics) = 0;
79     int init(Yaz_Z_Server *server,
80              Z_InitRequest *initRequest,
81              Z_InitResponse *initResponse);
82     int recv(Yaz_Z_Server *server, Z_APDU *apdu);
83
84     ODR odr_encode();
85     ODR odr_decode();
86  private:
87     Z_Records *pack_records (Yaz_Z_Server *s,
88                              const char *resultSetName,
89                              int start, int num,
90                              Z_RecordComposition *comp,
91                              int *next, int *pres,
92                              int *oid);
93
94     void fetch_via_piggyback (Yaz_Z_Server *s,
95                               Z_SearchRequest *searchRequest,
96                               Z_SearchResponse *searchResponse);
97     void fetch_via_present (Yaz_Z_Server *s,
98                             Z_PresentRequest *req, Z_PresentResponse *res);
99
100     int m_preferredMessageSize;
101     int m_maximumRecordSize;
102     ODR m_odr_encode;
103     ODR m_odr_decode;
104 };
105
106 class YAZ_EXPORT Yaz_Z_Server_Facility_Info {
107     friend class Yaz_Z_Server;
108     IYaz_Server_Facility *m_facility;
109     char *m_name;
110     Yaz_Z_Server_Facility_Info *m_next;
111 };
112
113
114
115 class YAZ_EXPORT Yaz_Z_Server : public Yaz_Z_Assoc {
116 public:
117     Yaz_Z_Server(IYaz_PDU_Observable *the_PDU_Observable);
118     virtual ~Yaz_Z_Server();
119     virtual void recv_Z_PDU(Z_APDU *apdu);
120     void facility_add(IYaz_Server_Facility *facility, const char *name);
121     void facility_reset ();
122
123
124  private:
125     Yaz_Z_Server_Facility_Info *m_facilities;
126 };
127
128 class YAZ_EXPORT Yaz_USMARC {
129  public:
130     const char *get_record(int position);
131 };