Joedb 10.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Client_Command_Processor.h
Go to the documentation of this file.
1#ifndef joedb_Client_Command_Processor_declared
2#define joedb_Client_Command_Processor_declared
3
7
8#include <chrono>
9
10namespace joedb
11{
12 class Client;
13
14 /// @ingroup ui
16 {
17 private:
18 Blob_Reader_Command_Processor blob_processor;
19
20 protected:
22
23 static bool sleep(float seconds, std::ostream &out);
24 virtual std::string get_name() const {return "readonly_client";}
25 virtual int64_t pull(std::ostream &out, std::chrono::milliseconds wait);
26
27 public:
29 blob_processor(client.get_journal().get_file()),
31 {}
32
33 void write_prompt(std::ostream &out) const override;
34
36 (
37 Command_Interpreter &interpreter,
38 std::istream &in,
39 std::ostream &out
40 )
41 {
42 interpreter.add_processor(blob_processor);
43 interpreter.set_parent(this);
44 interpreter.main_loop(in, out);
45 }
46
48 (
49 std::string_view command,
50 std::istream &parameters,
51 std::istream &in,
52 std::ostream &out
53 ) override;
54 };
55
56 /// @ingroup ui
58 {
59 private:
60 Writable_Client &get_writable_client()
61 {
63 }
64
65 std::string get_name() const override {return "writable_client";}
66 int64_t pull(std::ostream &out, std::chrono::milliseconds wait) override;
67
68 public:
73
75 (
76 std::string_view command,
77 std::istream &parameters,
78 std::istream &in,
79 std::ostream &out
80 ) override;
81 };
82}
83
84#endif
virtual int64_t pull(std::ostream &out, std::chrono::milliseconds wait)
static bool sleep(float seconds, std::ostream &out)
virtual std::string get_name() const
void run_interpreter(Command_Interpreter &interpreter, std::istream &in, std::ostream &out)
void write_prompt(std::ostream &out) const override
Status process_command(std::string_view command, std::istream &parameters, std::istream &in, std::ostream &out) override
Handle concurrent access to a file with a joedb::Connection.
Definition Client.h:12
void set_parent(const Command_Interpreter *new_parent)
void main_loop(std::istream &in, std::ostream &out)
void add_processor(Command_Processor &processor)
Status process_command(std::string_view command, std::istream &parameters, std::istream &in, std::ostream &out) override
Writable specialization of Client.