[honey] Improve spelling table key encoding
[xapian.git] / xapian-core / backends / databasereplicator.h
blob2bfd871210156672ccad092d8baa864a73ae9aaf
1 /** @file databasereplicator.h
2 * @brief Class to manage replication of databases.
3 */
4 /* Copyright (C) 2008 Lemur Consulting Ltd
5 * Copyright (C) 2009,2010 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 #ifndef XAPIAN_INCLUDED_DATABASEREPLICATOR_H
24 #define XAPIAN_INCLUDED_DATABASEREPLICATOR_H
26 #include <string>
28 #include "xapian/types.h"
30 class RemoteConnection;
32 namespace Xapian {
34 /** Base class for database replicator objects.
36 * This is subclassed by each database backend which supports replication.
38 class DatabaseReplicator {
39 private:
40 /// Copies are not allowed.
41 DatabaseReplicator(const DatabaseReplicator &);
43 /// Assignment is not allowed.
44 void operator=(const DatabaseReplicator &);
46 protected:
47 /** Constructor to allow construction of subclasses from the open()
48 * method.
50 DatabaseReplicator() { }
52 public:
53 /** Destroy the replicator.
55 virtual ~DatabaseReplicator();
57 /** Open a DatabaseReplicator for the given path.
59 * The type of the database at the path is automatically detected.
61 static DatabaseReplicator * open(const std::string & path);
63 /** Check if the revision of the database is at least that of a target.
65 * @param rev The database revision.
66 * @param target The target revision.
68 virtual bool check_revision_at_least(const std::string & rev,
69 const std::string & target) const = 0;
71 /** Read and apply the next changeset.
73 * @param conn The remote connection manager.
75 * @param end_time The time to timeout at.
77 * @param db_valid Whether the database is known to be valid at the
78 * start of the changeset. If this is true, some additional checks
79 * are performed.
81 virtual std::string apply_changeset_from_conn(RemoteConnection & conn,
82 double end_time,
83 bool db_valid) const = 0;
85 /** Get a UUID for the replica.
87 * If the UUID cannot be read (for example, because the database is
88 * not valid), this should return the empty string, rather than
89 * raising an exception.
91 virtual std::string get_uuid() const = 0;
96 #endif /* XAPIAN_INCLUDED_DATABASEREPLICATOR_H */