00001 00004 /* Copyright 2008 Lemur Consulting Ltd 00005 * Copyright 2008,2011 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 #ifndef XAPIAN_INCLUDED_REPLICATION_H 00024 #define XAPIAN_INCLUDED_REPLICATION_H 00025 00026 #include "xapian/base.h" 00027 #include "xapian/visibility.h" 00028 00029 #include <string> 00030 00031 namespace Xapian { 00032 00034 struct XAPIAN_VISIBILITY_DEFAULT ReplicationInfo { 00036 int changeset_count; 00037 00039 int fullcopy_count; 00040 00046 bool changed; 00047 00048 ReplicationInfo() 00049 : changeset_count(0), 00050 fullcopy_count(0), 00051 changed(false) 00052 {} 00053 00054 void clear() { 00055 changeset_count = 0; 00056 fullcopy_count = 0; 00057 changed = false; 00058 } 00059 }; 00060 00062 class XAPIAN_VISIBILITY_DEFAULT DatabaseMaster { 00064 std::string path; 00065 00066 public: 00072 DatabaseMaster(const std::string & path_) : path(path_) {} 00073 00102 void write_changesets_to_fd(int fd, 00103 const std::string & start_revision, 00104 ReplicationInfo * info) const; 00105 00107 std::string get_description() const; 00108 }; 00109 00115 class XAPIAN_VISIBILITY_DEFAULT DatabaseReplica { 00117 class Internal; 00119 Xapian::Internal::RefCntPtr<Internal> internal; 00120 00121 public: 00123 DatabaseReplica(const DatabaseReplica & other); 00124 00126 void operator=(const DatabaseReplica & other); 00127 00129 DatabaseReplica(); 00130 00132 ~DatabaseReplica(); 00133 00146 DatabaseReplica(const std::string & path); 00147 00156 std::string get_revision_info() const; 00157 00165 void set_read_fd(int fd); 00166 00197 bool apply_next_changeset(ReplicationInfo * info, 00198 double reader_close_time); 00199 00207 void close(); 00208 00210 std::string get_description() const; 00211 }; 00212 00213 } 00214 00215 #endif /* XAPIAN_INCLUDED_REPLICATION_H */