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

include/om/omdatabase.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  * Copyright 2002 Olly Betts
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License as
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022  * USA
00023  * -----END-LICENCE-----
00024  */
00025 
00026 #ifndef OM_HGUARD_OMDATABASE_H
00027 #define OM_HGUARD_OMDATABASE_H
00028 
00029 #include "om/omdocument.h"
00030 #include "om/ompostlistiterator.h"
00031 #include "om/omtermlistiterator.h"
00032 #include "om/ompositionlistiterator.h"
00033 
00034 class OmWritableDatabase;
00035 
00046 class OmDatabase {
00047     public:
00056         void add_database(const OmDatabase & database);
00057     
00058     public:
00059         class Internal;
00061         Internal *internal;
00062 
00063     public:
00066         OmDatabase();
00067 
00070         OmDatabase(OmDatabase::Internal *internal);
00071 
00076         virtual ~OmDatabase();
00077 
00081         OmDatabase(const OmDatabase &other);
00082 
00086         virtual void operator=(const OmDatabase &other);
00087 
00093         void reopen();
00094 
00099         virtual std::string get_description() const;
00100 
00104         OmPostListIterator postlist_begin(const om_termname &tname) const;
00105 
00108         OmPostListIterator postlist_end(const om_termname &tname) const;
00109 
00113         OmTermIterator termlist_begin(om_docid did) const;
00114         
00117         OmTermIterator termlist_end(om_docid did) const;
00118 
00122         OmPositionListIterator positionlist_begin(om_docid did, const om_termname &tname) const;
00123 
00126         OmPositionListIterator positionlist_end(om_docid did, const om_termname &tname) const;
00127 
00130         OmTermIterator allterms_begin() const;
00131 
00134         OmTermIterator allterms_end() const;
00135 
00137         om_doccount get_doccount() const;
00138         
00140         om_doclength get_avlength() const;
00141 
00143         om_doccount get_termfreq(const om_termname & tname) const;
00144 
00151         bool term_exists(const om_termname & tname) const;
00152 
00162         om_termcount get_collection_freq(const om_termname & tname) const;
00163 
00166         om_doclength get_doclength(om_docid did) const;
00167 
00171         void keep_alive();
00172 
00185         OmDocument get_document(om_docid did) const;
00186 };
00187 
00190 class OmWritableDatabase : public OmDatabase {
00191     public:
00198         virtual ~OmWritableDatabase();
00199 
00202         OmWritableDatabase();
00203 
00206         OmWritableDatabase(OmDatabase::Internal *internal);
00207 
00211         OmWritableDatabase(const OmWritableDatabase &other);
00212 
00220         void operator=(const OmWritableDatabase &other);
00221 
00263         void flush();
00264 
00287         void begin_transaction();
00288 
00315         void commit_transaction();
00316 
00335         void cancel_transaction();
00336 
00366         om_docid add_document(const OmDocument & document);
00367 
00370         // FIXME: document more.
00371         void delete_document(om_docid did);
00372 
00375         // FIXME: document more.
00376         void replace_document(om_docid did, const OmDocument & document);
00377 
00382         std::string get_description() const;
00383 };
00384 
00385 const int OM_DB_CREATE_OR_OPEN = 1;
00386 const int OM_DB_CREATE = 2;
00387 const int OM_DB_CREATE_OR_OVERWRITE = 3;
00388 const int OM_DB_OPEN = 4;
00389 // Can't see any sensible use for this one
00390 // const int OM_DB_OVERWRITE = XXX;
00391 
00392 /* It's mostly harmless to provide prototypes for all the backends, even
00393  * if they may not all be built in - it means the failure will be at
00394  * link time rather than when a file is built.  The main benefit is
00395  * simplicity, but this also allows us to easily split the backends into
00396  * separate libraries and link the ones we actually use in an application.
00397  */
00398 
00404 OmDatabase OmAuto__open(const std::string &path);
00405 
00416 OmWritableDatabase OmAuto__open(const std::string &path, int action);
00417 
00422 OmDatabase OmQuartz__open(const std::string &dir);
00423 
00438 OmWritableDatabase
00439 OmQuartz__open(const std::string &dir, int action, int block_size = 8192);
00440 
00443 OmWritableDatabase OmInMemory__open();
00444 
00454 OmDatabase OmMuscat36DA__open(const std::string &R, const std::string &T, bool heavy_duty = true);
00455 
00466 OmDatabase OmMuscat36DA__open(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true);
00467 
00476 OmDatabase OmMuscat36DB__open(const std::string &DB, size_t cache_size = 30);
00477 
00487 OmDatabase OmMuscat36DB__open(const std::string &DB, const std::string &values = "", size_t cache_size = 30);
00488 
00501 OmDatabase OmRemote__open(const std::string &program, const std::string &args,
00502         unsigned int timeout = 10000);
00503 
00520 OmDatabase
00521 OmRemote__open(const std::string &host, unsigned int port,
00522         unsigned int timeout = 10000, unsigned int connect_timeout = 0);
00523 
00531 OmDatabase
00532 OmStub__open(const std::string &file);
00533 
00534 #endif /* OM_HGUARD_OMDATABASE_H */

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