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