00001 00004 /* Copyright 2008 Lemur Consulting Ltd 00005 * Copyright 2009,2010 Olly Betts 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00020 * USA 00021 */ 00022 00023 #include <config.h> 00024 00025 #include "databasereplicator.h" 00026 00027 #include "xapian/error.h" 00028 #include "xapian/version.h" // For XAPIAN_HAS_XXX_BACKEND. 00029 00030 #include "debuglog.h" 00031 #include "utils.h" 00032 00033 #ifdef XAPIAN_HAS_BRASS_BACKEND 00034 # include "brass/brass_databasereplicator.h" 00035 #endif 00036 #ifdef XAPIAN_HAS_CHERT_BACKEND 00037 # include "chert/chert_databasereplicator.h" 00038 #endif 00039 #ifdef XAPIAN_HAS_FLINT_BACKEND 00040 # include "flint/flint_databasereplicator.h" 00041 #endif 00042 00043 using namespace std; 00044 00045 namespace Xapian { 00046 00047 DatabaseReplicator::~DatabaseReplicator() 00048 { 00049 } 00050 00051 DatabaseReplicator * 00052 DatabaseReplicator::open(const string & path) 00053 { 00054 LOGCALL_STATIC_VOID(DB, "DatabaseReplicator::DatabaseReplicator", path); 00055 00056 #ifdef XAPIAN_HAS_CHERT_BACKEND 00057 if (file_exists(path + "/iamchert")) { 00058 return new ChertDatabaseReplicator(path); 00059 } 00060 #endif 00061 00062 #ifdef XAPIAN_HAS_FLINT_BACKEND 00063 if (file_exists(path + "/iamflint")) { 00064 return new FlintDatabaseReplicator(path); 00065 } 00066 #endif 00067 00068 #ifdef XAPIAN_HAS_BRASS_BACKEND 00069 if (file_exists(path + "/iambrass")) { 00070 return new BrassDatabaseReplicator(path); 00071 } 00072 #endif 00073 00074 throw DatabaseOpeningError("Couldn't detect type of database: " + path); 00075 } 00076 00077 }