common/remoteserver.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2006,2007 Olly Betts
00005  * Copyright (C) 2007 Lemur Consulting Ltd
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (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 USA
00020  */
00021 
00022 #ifndef XAPIAN_INCLUDED_REMOTESERVER_H
00023 #define XAPIAN_INCLUDED_REMOTESERVER_H
00024 
00025 #include "xapian/database.h"
00026 #include "xapian/enquire.h"
00027 #include "xapian/visibility.h"
00028 
00029 #include "remoteconnection.h"
00030 
00031 #include <map>
00032 #include <string>
00033 
00034 // Forward declaration
00035 namespace Xapian { class Weight; }
00036 
00037 using namespace std;
00038 
00040 class XAPIAN_VISIBILITY_DEFAULT RemoteServer : private RemoteConnection {
00042     void operator=(const RemoteServer &);
00043 
00045     RemoteServer(const RemoteServer &);
00046 
00051     Xapian::Database * db;
00052 
00054     Xapian::WritableDatabase * wdb;
00055 
00061     Xapian::timeout active_timeout;
00062 
00068     Xapian::timeout idle_timeout;
00069 
00071     map<string, Xapian::Weight *> wtschemes;
00072 
00074     message_type get_message(Xapian::timeout timeout, string & result,
00075                              message_type required_type = MSG_MAX);
00076 
00078     void send_message(reply_type type, const string &message);
00079 
00080     // all terms
00081     void msg_allterms(const std::string & message);
00082 
00083     // get document
00084     void msg_document(const std::string & message);
00085 
00086     // term exists?
00087     void msg_termexists(const std::string & message);
00088 
00089     // get collection freq
00090     void msg_collfreq(const std::string & message);
00091 
00092     // get termfreq
00093     void msg_termfreq(const std::string & message);
00094 
00095     // keep alive
00096     void msg_keepalive(const std::string & message);
00097 
00098     // get doclength
00099     void msg_doclength(const std::string & message);
00100 
00101     // set the query; return the mset
00102     void msg_query(const std::string & message);
00103 
00104     // get termlist
00105     void msg_termlist(const std::string & message);
00106 
00107     // get postlist
00108     void msg_postlist(const std::string & message);
00109 
00110     // get positionlist
00111     void msg_positionlist(const std::string &message);
00112 
00113     // reopen
00114     void msg_reopen(const std::string & message);
00115 
00116     // get updated doccount and avlength
00117     void msg_update(const std::string &message);
00118 
00119     // flush
00120     void msg_flush(const std::string & message);
00121 
00122     // cancel
00123     void msg_cancel(const string &message);
00124 
00125     // add document
00126     void msg_adddocument(const std::string & message);
00127 
00128     // delete document for compatiblity with protocol < 30.2
00129     void msg_deletedocument_pre_30_2(const std::string & message);
00130 
00131     // delete document
00132     void msg_deletedocument(const std::string & message);
00133 
00134     // delete document with unique term
00135     void msg_deletedocumentterm(const std::string & message);
00136 
00137     // replace document
00138     void msg_replacedocument(const std::string & message);
00139 
00140     // replace document with unique term
00141     void msg_replacedocumentterm(const std::string & message);
00142 
00143   public:
00156     RemoteServer(const std::vector<std::string> &dbpaths,
00157                  int fdin, int fdout,
00158                  Xapian::timeout active_timeout_,
00159                  Xapian::timeout idle_timeout_,
00160                  bool writable = false);
00161 
00163     ~RemoteServer();
00164 
00170     void run();
00171 
00173     void register_weighting_scheme(const Xapian::Weight &wt) {
00174         wtschemes[wt.name()] = wt.clone();
00175     }
00176 };
00177 
00178 #endif // XAPIAN_INCLUDED_REMOTESERVER_H

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.