xapian-core  1.4.26
databasereplicator.cc
Go to the documentation of this file.
1 
4 /* Copyright 2008 Lemur Consulting Ltd
5  * Copyright 2009,2010,2011,2012 Olly Betts
6  *
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.
11  *
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.
16  *
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
21  */
22 
23 #include <config.h>
24 
25 #include "databasereplicator.h"
26 
27 #include "xapian/error.h"
28 #include "xapian/version.h" // For XAPIAN_HAS_XXX_BACKEND.
29 
30 #include "debuglog.h"
31 #include "filetests.h"
32 
33 #if defined XAPIAN_HAS_GLASS_BACKEND && defined XAPIAN_HAS_REMOTE_BACKEND
35 #endif
36 #ifdef XAPIAN_HAS_CHERT_BACKEND
38 #endif
39 
40 using namespace std;
41 
42 namespace Xapian {
43 
44 DatabaseReplicator::~DatabaseReplicator()
45 {
46 }
47 
49 DatabaseReplicator::open(const string & path)
50 {
51  LOGCALL_STATIC(DB, DatabaseReplicator *, "DatabaseReplicator::open", path);
52 
53 #ifdef XAPIAN_HAS_CHERT_BACKEND
54  if (file_exists(path + "/iamchert")) {
55 # ifdef XAPIAN_HAS_REMOTE_BACKEND
56  return new ChertDatabaseReplicator(path);
57 # else
58  throw FeatureUnavailableError("Replication disabled");
59 # endif
60  }
61 #endif
62 
63 #ifdef XAPIAN_HAS_GLASS_BACKEND
64  if (file_exists(path + "/iamglass")) {
65 # ifdef XAPIAN_HAS_REMOTE_BACKEND
66  return new GlassDatabaseReplicator(path);
67 # else
68  throw FeatureUnavailableError("Replication disabled");
69 # endif
70  }
71 #endif
72 
73  if (file_exists(path + "/iamflint")) {
74  throw FeatureUnavailableError("Flint backend no longer supported");
75  }
76 
77  if (file_exists(path + "/iambrass")) {
78  throw FeatureUnavailableError("Brass backend no longer supported");
79  }
80 
81  throw DatabaseOpeningError("Couldn't detect type of database: " + path);
82 }
83 
84 }
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
#define LOGCALL_STATIC(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:491
Support for chert database replication.
DatabaseOpeningError indicates failure to open a database.
Definition: error.h:581
WritableDatabase open()
Construct a WritableDatabase object for a new, empty InMemory database.
Definition: dbfactory.h:104
STL namespace.
Utility functions for testing files.
Hierarchy of classes which Xapian can throw as exceptions.
Base class for database replicator objects.
Class to manage replication of databases.
Indicates an attempt to use a feature which is unavailable.
Definition: error.h:719
Define preprocessor symbols for the library version.
Support for glass database replication.
bool file_exists(const char *path)
Test if a file exists.
Definition: filetests.h:39
Debug logging macros.