tests/harness/backendmanager.h

Go to the documentation of this file.
00001 /* backendmanager.h
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #ifndef OM_HGUARD_BACKENDMANAGER_H
00023 #define OM_HGUARD_BACKENDMANAGER_H
00024 
00025 #include <xapian.h>
00026 #include <vector>
00027 
00028 // Paths to xapian-tcpsrv and xapian-progsrv.
00029 #ifdef __WIN32__
00030 // Under __WIN32__ we want \ path separators since we pass this path to
00031 // CreateProcess().
00032 # ifdef _MSC_VER
00033 #  ifdef DEBUG
00034 #   define XAPIAN_BIN_PATH "..\\win32\\Debug\\"
00035 #  else
00036 #   define XAPIAN_BIN_PATH "..\\win32\\Release\\"
00037 #  endif
00038 # else
00039 #  define XAPIAN_BIN_PATH "..\\bin\\" // mingw
00040 # endif
00041 #else
00042 # define XAPIAN_BIN_PATH "../bin/"
00043 #endif
00044 #define XAPIAN_TCPSRV XAPIAN_BIN_PATH"xapian-tcpsrv"
00045 #define XAPIAN_PROGSRV XAPIAN_BIN_PATH"xapian-progsrv"
00046 
00047 #ifdef __SUNPRO_CC
00048 class Xapian::WritableDatabase; // Sun's CC appears to need this to compile this file
00049 #endif
00050 
00051 class BackendManager {
00053     std::string datadir;
00054 
00056     void index_files_to_database(Xapian::WritableDatabase & database,
00057                                  const std::vector<std::string> & dbnames);
00058 
00059   protected:
00060     bool create_dir_if_needed(const std::string &dirname);
00061 
00062 #ifdef XAPIAN_HAS_INMEMORY_BACKEND
00064     Xapian::WritableDatabase getwritedb_inmemory(const std::vector<std::string> &dbnames);
00065 #endif
00066 
00067 #ifdef XAPIAN_HAS_REMOTE_BACKEND
00069     Xapian::Database getdb_remoteprog(const std::vector<std::string> &dbnames);
00070 
00072     Xapian::WritableDatabase getwritedb_remoteprog(const std::vector<std::string> &dbnames);
00073 
00075     Xapian::Database getdb_remotetcp(const std::vector<std::string> &dbnames);
00076 
00078     Xapian::WritableDatabase getwritedb_remotetcp(const std::vector<std::string> &dbnames);
00079 #endif
00080 
00081 #ifdef XAPIAN_HAS_FLINT_BACKEND
00082   protected:
00083     std::string createdb_flint(const std::vector<std::string> &dbnames);
00084 
00085   public:
00087     Xapian::WritableDatabase getwritedb_flint(const std::string & name,
00088                                               const std::vector<std::string> &files);
00089 #endif
00090 
00091 #ifdef XAPIAN_HAS_QUARTZ_BACKEND
00092   protected:
00093     std::string createdb_quartz(const std::vector<std::string> &dbnames);
00094 
00095   public:
00097     Xapian::WritableDatabase getwritedb_quartz(const std::string & name,
00098                                                const std::vector<std::string> &files);
00099 #endif
00100 
00101   public:
00103     BackendManager() { }
00104 
00106     virtual ~BackendManager() { } // FIXME: move out of header
00107 
00113     virtual const char * get_dbtype() const { return "none"; } // FIXME: move out of header
00114 
00117     void set_datadir(const std::string &datadir_) { datadir = datadir_; }
00118 
00121     const std::string & get_datadir() const { return datadir; }
00122 
00124     virtual Xapian::Database get_database(const std::vector<std::string> &dbnames);
00125 
00127     virtual Xapian::Database get_database(const std::string &dbname);
00128 
00130     virtual Xapian::WritableDatabase get_writable_database(const std::string & name, const std::string & file);
00131 
00133     virtual Xapian::Database get_remote_database(const std::vector<std::string> & files, unsigned int timeout);
00134 
00136     virtual Xapian::Database get_writable_database_as_database();
00137 
00139     virtual Xapian::WritableDatabase get_writable_database_again();
00140 
00142     static const char * get_xapian_progsrv_command();
00143 };
00144 
00145 #endif /* OM_HGUARD_BACKENDMANAGER_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.