00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OM_HGUARD_OMENQUIRE_H
00025 #define OM_HGUARD_OMENQUIRE_H
00026
00027 #include "om/omtypes.h"
00028 #include "om/omdocument.h"
00029 #include "om/omdatabase.h"
00030 #include "om/omerror.h"
00031 #include <string>
00032
00033 class OmQuery;
00034 class OmErrorHandler;
00035
00039 class OmMSetIterator {
00040 public:
00041 friend class OmMSet;
00042
00043 class Internal;
00045 Internal *internal;
00046
00047 friend bool operator==(const OmMSetIterator &a,
00048 const OmMSetIterator &b);
00049
00050 private:
00051 OmMSetIterator(Internal *internal_);
00052
00053 public:
00057 OmMSetIterator();
00058
00059 ~OmMSetIterator();
00060
00062 OmMSetIterator(const OmMSetIterator &other);
00063
00065 void operator=(const OmMSetIterator &other);
00066
00068 OmMSetIterator & operator++();
00069
00070 void operator++(int);
00071
00073 om_docid operator *() const;
00074
00093 OmDocument get_document() const;
00094
00101 om_doccount get_rank() const;
00102
00104 om_weight get_weight() const;
00105
00110 om_percent get_percent() const;
00111
00115 std::string get_description() const;
00116
00118
00119 typedef std::input_iterator_tag iterator_category;
00120 typedef om_docid value_type;
00121 typedef om_doccount_diff difference_type;
00122 typedef om_docid * pointer;
00123 typedef om_docid & reference;
00125 };
00126
00127 inline bool operator!=(const OmMSetIterator &a,
00128 const OmMSetIterator &b)
00129 {
00130 return !(a == b);
00131 }
00132
00136 class OmMSet {
00137 public:
00138 class Internal;
00140 Internal *internal;
00141
00142 public:
00143
00145
00146
00148 OmMSet();
00149
00151 ~OmMSet();
00152
00154 OmMSet(const OmMSet & other);
00155
00157 void operator=(const OmMSet &other);
00158
00174 void fetch(const OmMSetIterator &begin,
00175 const OmMSetIterator &end) const;
00176
00179 void fetch(const OmMSetIterator &item) const;
00180
00183 void fetch() const;
00184
00189 om_percent convert_to_percent(om_weight wt) const;
00190
00192 om_percent convert_to_percent(const OmMSetIterator &it) const;
00193
00201 om_doccount get_termfreq(const om_termname &tname) const;
00202
00210 om_weight get_termweight(const om_termname &tname) const;
00211
00218 om_doccount get_firstitem() const;
00219
00226 om_doccount get_matches_lower_bound() const;
00227
00237 om_doccount get_matches_estimated() const;
00238
00245 om_doccount get_matches_upper_bound() const;
00246
00252 om_weight get_max_possible() const;
00253
00267 om_weight get_max_attained() const;
00268
00269 om_doccount size() const;
00270
00271 om_doccount max_size() const;
00272
00273 bool empty() const;
00274
00275 void swap(OmMSet & other);
00276
00277 OmMSetIterator begin() const;
00278
00279 OmMSetIterator end() const;
00280
00281 OmMSetIterator back() const;
00282
00292 OmMSetIterator operator[](om_doccount i) const;
00293
00295
00296 typedef std::input_iterator_tag iterator_category;
00297 typedef OmMSetIterator value_type;
00298 typedef OmMSetIterator iterator;
00299 typedef OmMSetIterator const_iterator;
00300 typedef OmMSetIterator & reference;
00301 typedef OmMSetIterator & const_reference;
00302 typedef OmMSetIterator * pointer;
00303 typedef om_doccount_diff difference_type;
00304 typedef om_doccount size_type;
00306
00310 std::string get_description() const;
00311 };
00312
00314 class OmESetIterator {
00315 public:
00316 friend class OmESet;
00317 class Internal;
00319 Internal *internal;
00320
00321 friend bool operator==(const OmESetIterator &a,
00322 const OmESetIterator &b);
00323
00324 private:
00325
00326 OmESetIterator(Internal *internal_);
00327
00328 public:
00332 OmESetIterator();
00333
00335 ~OmESetIterator();
00336
00338 OmESetIterator(const OmESetIterator &other);
00339
00341 void operator=(const OmESetIterator &other);
00342
00343 OmESetIterator & operator++();
00344
00345 void operator++(int);
00346
00348 const om_termname & operator *() const;
00349
00351 om_weight get_weight() const;
00352
00356 std::string get_description() const;
00357
00359
00360 typedef std::input_iterator_tag iterator_category;
00361 typedef om_termname value_type;
00362 typedef om_termcount_diff difference_type;
00363 typedef om_termname * pointer;
00364 typedef om_termname & reference;
00366 };
00367
00368 inline bool
00369 operator!=(const OmESetIterator &a, const OmESetIterator &b)
00370 {
00371 return !(a == b);
00372 }
00373
00378 class OmESet {
00379 public:
00380 class Internal;
00382 Internal *internal;
00383
00385 OmESet();
00386
00388 ~OmESet();
00389
00391 OmESet(const OmESet & other);
00392
00394 void operator=(const OmESet &other);
00395
00400 om_termcount get_ebound() const;
00401
00403 om_termcount size() const;
00404
00406 bool empty() const;
00407
00409 OmESetIterator begin() const;
00410
00412 OmESetIterator end() const;
00413
00418 std::string get_description() const;
00419 };
00420
00426 class OmRSet {
00427 public:
00429 class Internal;
00431 Internal *internal;
00432
00434 OmRSet(const OmRSet &rset);
00435
00437 void operator=(const OmRSet &rset);
00438
00440 OmRSet();
00441
00443 ~OmRSet();
00444
00446 om_doccount size() const;
00447
00449 bool empty() const;
00450
00452 void add_document(om_docid did);
00453
00455 void add_document(const OmMSetIterator & i) { add_document(*i); }
00456
00458 void remove_document(om_docid did);
00459
00461 void remove_document(const OmMSetIterator & i) { remove_document(*i); }
00462
00464 bool contains(om_docid did) const;
00465
00467 bool contains(const OmMSetIterator & i) { return contains(*i); }
00468
00473 std::string get_description() const;
00474 };
00475
00478 class OmMatchDecider {
00479 public:
00482 virtual int operator()(const OmDocument &doc) const = 0;
00483
00485 virtual ~OmMatchDecider() {}
00486 };
00487
00490 class OmExpandDecider {
00491 public:
00494 virtual int operator()(const om_termname & tname) const = 0;
00495
00497 virtual ~OmExpandDecider() {}
00498 };
00499
00513 class OmEnquire {
00514 private:
00516 OmEnquire(const OmEnquire &);
00517
00519 void operator=(const OmEnquire &);
00520
00521 public:
00522 class Internal;
00524 Internal *internal;
00525
00541 OmEnquire(const OmDatabase &databases,
00542 OmErrorHandler * errorhandler_ = 0);
00543
00552 ~OmEnquire();
00553
00561 void set_query(const OmQuery & query_);
00562
00569 const OmQuery & get_query();
00570
00592 OmMSet get_mset(om_doccount first,
00593 om_doccount maxitems,
00594 const OmRSet * omrset = 0,
00595 const OmSettings * moptions = 0,
00596 const OmMatchDecider * mdecider = 0) const;
00597
00613 OmESet get_eset(om_termcount maxitems,
00614 const OmRSet & omrset,
00615 const OmSettings * eoptions = 0,
00616 const OmExpandDecider * edecider = 0) const;
00617
00647 OmTermIterator get_matching_terms_begin(om_docid did) const;
00648
00650 OmTermIterator get_matching_terms_end(om_docid did) const;
00651
00675 OmTermIterator get_matching_terms_begin(const OmMSetIterator &it) const;
00676
00678 OmTermIterator get_matching_terms_end(const OmMSetIterator &it) const;
00679
00682 void register_match_decider(const std::string &name,
00683 const OmMatchDecider *mdecider = NULL);
00684
00688 std::string get_description() const;
00689 };
00690
00691 #endif