Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/om/omquery.h

Go to the documentation of this file.
00001 
00004 /* ----START-LICENCE----
00005  * Copyright 1999,2000,2001 BrightStation PLC
00006  * Copyright 2002 Ananova Ltd
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021  * USA
00022  * -----END-LICENCE-----
00023  */
00024 
00025 #ifndef OM_HGUARD_OMQUERY_H
00026 #define OM_HGUARD_OMQUERY_H
00027 
00028 #ifndef OM_HGUARD_OMTYPES_H
00029 #include "om/omtypes.h"
00030 #endif
00031 #ifndef OM_HGUARD_OMTERMLISTITERATOR_H
00032 #include "om/omtermlistiterator.h"
00033 #endif
00034 
00038 class OmQuery {
00039     public:
00041         class Internal;
00043         Internal *internal;
00044 
00046         typedef enum {
00048             OP_AND,
00049 
00051             OP_OR,
00052 
00054             OP_AND_NOT,
00055 
00057             OP_XOR,
00058 
00060             OP_AND_MAYBE,
00061 
00063             OP_FILTER,
00064 
00073             OP_NEAR,
00074 
00083             OP_PHRASE,
00084 
00091             OP_WEIGHT_CUTOFF,
00092 
00096             OP_ELITE_SET
00097         } op;
00098 
00100         OmQuery(const OmQuery & copyme);
00101 
00103         OmQuery & operator=(const OmQuery & copyme);
00104 
00113         OmQuery();
00114 
00116         ~OmQuery();
00117 
00119         OmQuery(const om_termname & tname_,
00120                 om_termcount wqf_ = 1,
00121                 om_termpos term_pos_ = 0);
00122 
00124         OmQuery(OmQuery::op op_, const OmQuery & left, const OmQuery & right);
00125 
00126         /* A query consisting of two subquery pointers, opp-ed together. */
00127         // Don't have this because vector iterators are often implemented as
00128         // simple pointers, so this would override the template class and
00129         // produce unexpected results.  Only plausible solution we can think
00130         // of so far is to change to using construction methods (eg,
00131         // static OmQuery::create_vector(op, begin, end) and
00132         // static OmQuery::create_pair(op, begin, end)
00133         //OmQuery(OmQuery::op op_, const OmQuery * left, const OmQuery * right);
00134 
00136         OmQuery(OmQuery::op op_,
00137                 const om_termname & left, const om_termname & right);
00138 
00149         template <class Iterator>
00150         OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend);
00151 
00157         template <class SubQ>
00158         OmQuery(OmQuery::op op_, SubQ q);
00159 
00162         void set_window(om_termpos window);
00163 
00166         void set_cutoff(om_weight cutoff);
00167 
00169         void set_elite_set_size(om_termcount size);
00170 
00175         om_termcount get_length() const;
00176 
00182         om_termcount set_length(om_termcount qlen);
00183 
00189         OmTermIterator get_terms_begin() const;
00190 
00194         OmTermIterator get_terms_end() const;
00195 
00197         //  an empty iterator ctor)
00198         bool is_empty() const;
00199                 
00203         std::string get_description() const;
00204 
00205     private:
00206         void add_subquery(const OmQuery & subq);
00207         void add_subquery(const OmQuery * subq);
00208         void add_subquery(const om_termname & tname);
00209         void start_construction(OmQuery::op op_);
00210         void end_construction();
00211         void abort_construction();
00212 };
00213 
00214 template <class Iterator>
00215 OmQuery::OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend) : internal(0)
00216 {
00217     try {
00218         start_construction(op_);
00219 
00220         /* Add all the elements */
00221         while (qbegin != qend) {
00222             add_subquery(*qbegin);
00223             ++qbegin;
00224         }
00225 
00226         end_construction();
00227     } catch (...) {
00228         abort_construction();
00229         throw;
00230     }
00231 }
00232 
00233 template <class SubQ>
00234 OmQuery::OmQuery(OmQuery::op op_, SubQ q) : internal(0)
00235 {
00236     try {
00237         start_construction(op_);
00238         add_subquery(q);
00239         end_construction();
00240     } catch (...) {
00241         abort_construction();
00242         throw;
00243     }
00244 }
00245 
00246 inline
00247 OmQuery::OmQuery(OmQuery::op op_,
00248                  const om_termname & left,
00249                  const om_termname & right) : internal(0)
00250 {
00251     try {
00252         start_construction(op_);
00253         add_subquery(left);
00254         add_subquery(right);
00255         end_construction();
00256     } catch (...) {
00257         abort_construction();
00258         throw;
00259     }
00260 }
00261 
00262 #endif /* OM_HGUARD_OMQUERY_H */

Documentation for Xapian (version 0.6.3).
Generated on 14 Dec 2002 by Doxygen 1.2.15.