[glass] Elide component_of counter in first leaf
[xapian.git] / xapian-core / backends / databasereplicator.cc
blobed0e76004009fdd03ac0119c8dc99a090ba8e7b1
1 /** @file databasereplicator.cc
2 * @brief Support class for database replication.
3 */
4 /* Copyright 2008 Lemur Consulting Ltd
5 * Copyright 2009,2010,2011,2012 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
23 #include <config.h>
25 #include "databasereplicator.h"
27 #include "xapian/error.h"
28 #include "xapian/version.h" // For XAPIAN_HAS_XXX_BACKEND.
30 #include "debuglog.h"
31 #include "filetests.h"
33 #ifdef XAPIAN_HAS_GLASS_BACKEND
34 # include "glass/glass_databasereplicator.h"
35 #endif
36 #ifdef XAPIAN_HAS_CHERT_BACKEND
37 # include "chert/chert_databasereplicator.h"
38 #endif
40 using namespace std;
42 namespace Xapian {
44 DatabaseReplicator::~DatabaseReplicator()
48 DatabaseReplicator *
49 DatabaseReplicator::open(const string & path)
51 LOGCALL_STATIC_VOID(DB, "DatabaseReplicator::DatabaseReplicator", path);
53 #ifdef XAPIAN_HAS_CHERT_BACKEND
54 if (file_exists(path + "/iamchert")) {
55 return new ChertDatabaseReplicator(path);
57 #endif
59 #ifdef XAPIAN_HAS_GLASS_BACKEND
60 if (file_exists(path + "/iamglass")) {
61 return new GlassDatabaseReplicator(path);
63 #endif
65 if (file_exists(path + "/iamflint")) {
66 throw FeatureUnavailableError("Flint backend no longer supported");
69 if (file_exists(path + "/iambrass")) {
70 throw FeatureUnavailableError("Brass backend no longer supported");
73 throw DatabaseOpeningError("Couldn't detect type of database: " + path);