source: main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h@ 21326

Last change on this file since 21326 was 15802, checked in by mdewsnip, 16 years ago

(Adding dynamic classifiers) Changing the way information is stored in FilterRequest_t objects for the sqlbrowsefilter requests.

  • Property svn:executable set to *
File size: 11.5 KB
Line 
1/**********************************************************************
2 *
3 * comtypes.h --
4 * Copyright (C) 1999,2004 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26
27#ifndef COMTYPES_H
28#define COMTYPES_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32
33#if defined(GSDL_USE_OBJECTSPACE)
34# include <ospace\std\vector>
35# include <ospace\std\list>
36# include <ospace\std\memory> // for pair
37# include <ospace\std\map>
38#elif defined(GSDL_USE_STL_H)
39# include <vector.h>
40# include <list.h>
41# include <memory.h> // for pair
42# include <map.h>
43#else
44# include <vector>
45# include <list>
46# include <memory> // for pair
47# include <map>
48#endif
49
50
51enum comerror_t {noError, authenticationFailure, protocolError,
52 configurationError, systemProblem, syntaxError};
53text_t get_comerror_string (comerror_t err);
54
55
56// ShortColInfo ::= SEQUENCE {
57// name GeneralString,
58// host GeneralString,
59// port INTEGER
60// }
61struct ShortColInfo_t {
62 void clear ();
63 ShortColInfo_t () {clear();}
64
65 text_t name;
66 text_t host;
67 int port;
68};
69
70// for collection metadata: metadata name -> lang -> value
71// for collection macros: macro name -> params -> value
72typedef map<text_t, text_tmap, lttext_t> collectionmeta_map;
73
74#define CCSUniformSearchResultsFormatting 1
75
76#define SIcasefold 1
77#define SIstem 2
78#define SIaccentfold 4
79
80struct ColInfoResponse_t {
81 void clear ();
82 ColInfoResponse_t () {clear();}
83 text_t get_collectionmeta(text_t name, text_t lang);
84
85 ShortColInfo_t shortInfo;
86 bool useBook; //whether we want to display the book
87 bool isPublic;
88 bool isBeta;
89 bool isSegmented;
90 bool isCollectGroup; // used to group a set of collections as one item on the home page
91 unsigned long buildDate;
92 text_tarray ccsCols; // empty if collection does not use cross-collection searching
93 int ccsOptions; // uses CCS #defines from above
94 int stemIndexes; // uses SI #defines from above
95 text_tarray languages;
96 unsigned long numDocs; // 0 if not known
97 unsigned long numSections; // 0 if not known
98 unsigned long numWords; // 0 if not known
99 unsigned long numBytes; // 0 if not known
100 collectionmeta_map collectionmeta;
101 text_tmap format;
102 collectionmeta_map collection_macros; // for collectionmacro config directive (> gsdl 2.53)
103 text_tmap building;
104 text_t httpdomain; // GRB: could these two http items need removing
105 text_t httpprefix;
106 text_t receptionist;
107 text_t buildType; // 'mg' or 'mgpp' or 'lucene'
108 text_t authenticate; // 'document' or 'collection'
109 text_t auth_group; // 'mygroup' 'yourgroup'
110 text_tmap public_documents; // the acl to allow access to listed documents
111 text_tmap private_documents; // the acl to disallow access to listed documents
112 text_tmap dynamic_classifiers;
113};
114
115
116// -- filter options which might be supported for the QueryFilter
117// --
118// -- onePerQuery StartResults integer
119// -- onePerQuery EndResults integer
120// -- onePerQuery QueryType enumerated (boolean, ranked)
121// -- onePerTerm Term string ???
122// -- onePerTerm Casefold boolean
123// -- onePerTerm Stem boolean
124// -- onePerTerm Index enumerated
125// -- onePerTerm Subcollection enumerated
126// --
127// -- filter options which might be supported for the BrowseFilter
128// --
129// -- onePerQuery StartResults integer
130// -- onePerQuery EndResults integer
131// -- onePerQuery ParentNode string ("" will return the browsing available)
132// --
133// -- The NullFilter always returns the set it was given, it doesn't have
134// -- any options
135
136// InfoFiltersResponse ::= SEQUENCE {
137// filterNames StringSet
138// }
139struct InfoFiltersResponse_t {
140 void clear ();
141
142 text_tset filterNames;
143};
144
145// InfoFilterOptionsRequest ::= SEQUENCE {
146// filterName GeneralString
147// }
148struct InfoFilterOptionsRequest_t {
149 void clear ();
150
151 text_t filterName;
152};
153
154// FilterOption ::= SEQUENCE {
155// name GeneralString,
156// type ENUMERATED {booleant(0), integert(1), enumeratedt(2), stringt(3)},
157// repeatable ENUMERATED {onePerQuery(0), onePerTerm(1), nPerTerm(2)},
158// defaultValue GeneralString,
159// -- the interpretation of the validValues depends on the type
160// -- for boolean: the first value is the false value, the second is true value
161// -- for integer: the first value is the minimum, the second the maximum
162// -- for enumerated: all values a listed
163// -- for string: this value is ignored
164// validValues StringSequence
165// }
166struct FilterOption_t {
167 void clear ();
168 void check_defaultValue ();
169 FilterOption_t () {clear();}
170
171 text_t name;
172
173 enum type_t {booleant=0, integert=1, enumeratedt=2, stringt=3};
174 type_t type;
175
176 enum repeatable_t {onePerQuery=0, onePerTerm=1, nPerTerm=2};
177 repeatable_t repeatable;
178
179 text_t defaultValue;
180 text_tarray validValues;
181};
182
183bool operator==(const FilterOption_t &x, const FilterOption_t &y);
184bool operator<(const FilterOption_t &x, const FilterOption_t &y);
185
186
187typedef map<text_t, FilterOption_t, lttext_t> FilterOption_tmap;
188
189
190// InfoFilterOptionsResponse ::= SEQUENCE {
191// filterOptions SET OF FilterOption
192// }
193struct InfoFilterOptionsResponse_t {
194 void clear ();
195
196 FilterOption_tmap filterOptions;
197};
198
199
200// OptionValue ::= SEQUENCE {
201// name GeneralString,
202// value GeneralString
203// }
204struct OptionValue_t {
205 void clear ();
206
207 text_t name;
208 text_t value;
209};
210
211typedef vector<OptionValue_t> OptionValue_tarray;
212
213
214// -- Terms are presented in the same order that they are requested,
215// -- any information relating to the terms is in reference to the
216// -- index specified for that term.
217//
218// FilterRequest ::= SEQUENCE {
219// filterName [0] GeneralString,
220// filterOptions [1] IMPLICIT SEQUENCE OF OptionValue,
221// docSet [2] IMPLICIT StringSequence, -- the OID "" represents everything
222// filterResultOptions [3] IMPLICIT BIT STRING {termFreq(0), matchTerms(1), OID(2),
223// subCol(3), ranking(4), docFreq(5),
224// metadata(6)}
225//
226// -- the next set of options are for the metadata request,
227// -- they can be left blank if metadata is not wanted
228// requestParams [4] IMPLICIT GeneralString, -- used to negotiate the metadata content
229// refParams [5] IMPLICIT GeneralString, -- used to decide whether to return a
230// -- reference to the data or the actual data
231// fields [6] IMPLICIT StringSet
232// getParents [7] IMPLICIT BOOLEAN -- gets metadata of all parents too
233// }
234#define FRtermFreq 1
235#define FRmatchTerms 2
236#define FROID 4
237#define FRsubCol 8
238#define FRranking 16
239#define FRdocFreq 32
240#define FRmetadata 64
241// used to indicate a full text browse query for mgpp
242#define FRfullTextBrowse 128
243
244struct FilterRequest_t {
245 void clear ();
246 FilterRequest_t () {clear();}
247
248 text_t filterName;
249 text_t filterLang; // non empty if we want info to be retrived in language specific
250 OptionValue_tarray filterOptions;
251 text_tarray docSet; // empty if not used
252 int filterResultOptions; // use the FR* defines above
253
254 text_t requestParams; // empty if not used
255 text_t refParams; // empty if not used
256 text_tset fields; // empty if not used
257 bool getParents; // defaults to false
258};
259
260
261// TermInfo ::= SEQUENCE {
262// term [0] GeneralString,
263// freq [1] IMPLICIT INTEGER, -- 0 if not requested
264// matchTerms [2] IMPLICIT StringSequence -- empty if not requested
265// }
266struct TermInfo_t {
267 void clear ();
268 TermInfo_t () {clear();}
269
270 text_t term;
271 int freq; // 0 if not requested
272 text_tarray matchTerms; // empty if not requested
273};
274
275typedef vector<TermInfo_t> TermInfo_tarray;
276
277
278// MetadataInfo ::= SEQUENCE {
279// params [0] IMPLICIT GeneralString,
280// isRef [1] IMPLICIT BOOLEAN,
281// values [3] IMPLICIT SEQUENCE OF GeneralString,
282// name [4] IMPLICIT GeneralString
283// }
284struct MetadataInfo_t {
285 text_t params;
286 bool isRef;
287 text_tarray values;
288 MetadataInfo_t *parent;
289
290 void clear ();
291 MetadataInfo_t ();
292 MetadataInfo_t (const MetadataInfo_t &x); // copy constructor
293 ~MetadataInfo_t ();
294 MetadataInfo_t &operator=(const MetadataInfo_t &x);
295};
296
297typedef map<text_t, MetadataInfo_t, lttext_t> MetadataInfo_tmap;
298
299// ResultDocInfo ::= SEQUENCE {
300// OID [0] IMPLICIT GeneralString,
301// ranking [1] IMPLICIT INTEGER, -- 0 if not requested, range 0-10000
302// docFreq [2] IMPLICIT SEQUENCE OF INTEGER, -- empty if not requested
303// metadata [3] IMPLICIT SEQUENCE OF MetadataInfo, -- no longer a SEQUENCE (SET maybe??)
304// classifier_metadata_type [4] IMPLICIT GeneralString, -- empty if not requested
305// classifier_metadata_offset [5] IMPLICIT INTEGER, -- 0 if not requested
306// }
307struct ResultDocInfo_t {
308 void clear ();
309 ResultDocInfo_t () {clear();}
310
311 text_t OID;
312 int result_num; // place in results list
313 int ranking; // 0 if not requested (real ranking*10000)
314 int num_terms_matched; // not available on all versions of mg
315 int num_phrase_match; // not available on all versions of mg
316 vector<int> docFreq; // empty if not requested
317 MetadataInfo_tmap metadata; // empty if not requested
318 text_t classifier_metadata_type; // empty if not requested
319 int classifier_metadata_offset; // 0 if not requested
320 ResultDocInfo_t &operator=(const ResultDocInfo_t &x);
321};
322
323typedef vector<ResultDocInfo_t> ResultDocInfo_tarray;
324
325
326// FilterResponse ::= SEQUENCE {
327// numDocs [0] IMPLICIT INTEGER,
328// isApprox [1] ENUMERATED {Exact(0), Approximate(1), MoreThan(2)}, -- whether numDocs is approximate
329// termInfo [2] IMPLICIT SEQUENCE OF TermInfo, -- empty if not required
330// docInfo [3] IMPLICIT SEQUENCE OF ResultDocInfo -- empty if not required
331// }
332
333enum isapprox {Exact=0, Approximate=1, MoreThan=2};
334
335struct FilterResponse_t {
336 void clear ();
337 FilterResponse_t () {clear();}
338
339 text_t error_message; // Currently only used by Lucene
340 int numDocs;
341 isapprox isApprox;
342 TermInfo_tarray termInfo; // empty if not requested
343 ResultDocInfo_tarray docInfo; // empty if not requested
344 text_tset stopwords;
345
346 FilterResponse_t &operator=(const FilterResponse_t &x);
347};
348
349
350// DocumentRequest ::= SEQUENCE {
351// OID GeneralString,
352// docType GeneralString,
353// docFormat GeneralString
354// }
355struct DocumentRequest_t {
356 void clear ();
357 DocumentRequest_t () {clear();}
358
359 text_t OID;
360 text_t docType;
361 text_t docFormat;
362};
363
364
365// DocumentResponse ::= SEQUENCE {
366// doc OCTET STRING
367// }
368
369struct DocumentResponse_t {
370 void clear ();
371 DocumentResponse_t () {clear();}
372
373 text_t doc;
374};
375
376
377#endif
378
Note: See TracBrowser for help on using the repository browser.