xapian-core  1.4.26
dbfactory_remote.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2006,2007,2008,2010,2011,2014 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <config.h>
22 
23 #include <xapian/dbfactory.h>
24 
25 #include "debuglog.h"
26 #include "net/progclient.h"
27 #include "net/remotetcpclient.h"
28 
29 #include <string>
30 
31 using namespace std;
32 
33 namespace Xapian {
34 
35 #if defined __GNUC__ && defined __MINGW32__
36 // Avoid deprecation warnings about useconds_t on mingw.
37 # pragma GCC diagnostic push
38 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
39 #endif
40 
41 Database
42 Remote::open(const string &host, unsigned int port, useconds_t timeout_,
43  useconds_t connect_timeout)
44 {
45  LOGCALL_STATIC(API, Database, "Remote::open", host | port | timeout_ | connect_timeout);
46  RETURN(Database(new RemoteTcpClient(host, port, timeout_ * 1e-3,
47  connect_timeout * 1e-3, false, 0)));
48 }
49 
51 Remote::open_writable(const string &host, unsigned int port,
52  useconds_t timeout_, useconds_t connect_timeout,
53  int flags)
54 {
55  LOGCALL_STATIC(API, WritableDatabase, "Remote::open_writable", host | port | timeout_ | connect_timeout | flags);
56  RETURN(WritableDatabase(new RemoteTcpClient(host, port, timeout_ * 1e-3,
57  connect_timeout * 1e-3, true,
58  flags)));
59 }
60 
62 Remote::open(const string &program, const string &args,
63  useconds_t timeout_)
64 {
65  LOGCALL_STATIC(API, Database, "Remote::open", program | args | timeout_);
66  RETURN(Database(new ProgClient(program, args, timeout_ * 1e-3, false, 0)));
67 }
68 
70 Remote::open_writable(const string &program, const string &args,
71  useconds_t timeout_, int flags)
72 {
73  LOGCALL_STATIC(API, WritableDatabase, "Remote::open_writable", program | args | timeout_ | flags);
74  RETURN(WritableDatabase(new ProgClient(program, args,
75  timeout_ * 1e-3, true, flags)));
76 }
77 
78 #if defined __GNUC__ && defined __MINGW32__
79 # pragma GCC diagnostic pop
80 #endif
81 
82 }
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
#define RETURN(A)
Definition: debuglog.h:493
This class is used to access a database, or a group of databases.
Definition: database.h:68
WritableDatabase open()
Construct a WritableDatabase object for a new, empty InMemory database.
Definition: dbfactory.h:104
STL namespace.
TCP/IP socket based RemoteDatabase implementation.
TCP/IP socket based RemoteDatabase implementation.
This class provides read/write access to a database.
Definition: database.h:789
Implementation of RemoteDatabase using a spawned server.
Definition: progclient.h:34
Implementation of RemoteDatabase using a spawned server.
WritableDatabase open_writable(const std::string &host, unsigned int port, useconds_t timeout=0, useconds_t connect_timeout=10000, int flags=0)
Construct a WritableDatabase object for update access to a remote database accessed via a TCP connect...
Factory functions for constructing Database and WritableDatabase objects.
Debug logging macros.