xapian-core  2.0.0
progclient.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2010,2011,2014,2019,2023,2024 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, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_PROGCLIENT_H
22 #define XAPIAN_INCLUDED_PROGCLIENT_H
23 
24 #include <string>
25 #include <string_view>
26 
27 #include <sys/types.h>
28 
30 
37 class ProgClient : public RemoteDatabase {
39  ProgClient& operator=(const ProgClient&) = delete;
40 
42  ProgClient(const ProgClient&) = delete;
43 
44 #ifndef __WIN32__
46  pid_t child;
47 #else
49  HANDLE child;
50 #endif
51 
67  static std::pair<int, std::string> run_program(std::string_view progname,
68  std::string_view args,
69 #ifndef __WIN32__
70  pid_t& child
71 #else
72  HANDLE& child
73 #endif
74  );
75 
76  public:
85  ProgClient(std::string_view progname,
86  std::string_view args,
87  double timeout_,
88  bool writable,
89  int flags)
90  : RemoteDatabase(run_program(progname, args, child),
91  timeout_,
92  writable,
93  flags)
94  {}
95 
97  ~ProgClient();
98 };
99 
100 #endif // XAPIAN_INCLUDED_PROGCLIENT_H
Implementation of RemoteDatabase using a spawned server.
Definition: progclient.h:37
static std::pair< int, std::string > run_program(std::string_view progname, std::string_view args, pid_t &child)
Start the child process.
Definition: progclient.cc:51
ProgClient(const ProgClient &)=delete
Don't allow copying.
ProgClient(std::string_view progname, std::string_view args, double timeout_, bool writable, int flags)
Constructor.
Definition: progclient.h:85
ProgClient & operator=(const ProgClient &)=delete
Don't allow assignment.
pid_t child
Process id of the child process.
Definition: progclient.h:46
~ProgClient()
Destructor.
Definition: progclient.cc:248
RemoteDatabase is the baseclass for remote database implementations.
RemoteDatabase is the baseclass for remote database implementations.