Joedb 10.3.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 void print_status(std::ostream &out);
21
22 protected:
24
25 static void sleep(int seconds, std::ostream &out);
26 virtual std::string get_name() const {return "readonly_client";}
27 virtual int64_t pull(std::ostream &out, std::chrono::milliseconds wait);
28
29 public:
31 blob_processor(client.get_journal().get_file()),
33 {}
34
35 void write_prompt(std::ostream &out) const override;
36
38 (
39 Command_Interpreter &interpreter,
40 std::istream &in,
41 std::ostream &out
42 )
43 {
44 interpreter.add_processor(blob_processor);
45 interpreter.set_parent(this);
46 interpreter.main_loop(in, out);
47 }
48
50 (
51 const std::string &command,
52 std::istream &parameters,
53 std::istream &in,
54 std::ostream &out
55 ) override;
56 };
57
58 /// @ingroup ui
60 {
61 private:
62 Writable_Client &get_writable_client()
63 {
65 }
66
67 std::string get_name() const override {return "writable_client";}
68 int64_t pull(std::ostream &out, std::chrono::milliseconds wait) override;
69
70 public:
75
77 (
78 const std::string &command,
79 std::istream &parameters,
80 std::istream &in,
81 std::ostream &out
82 ) override;
83 };
84}
85
86#endif
virtual int64_t pull(std::ostream &out, std::chrono::milliseconds wait)
Status process_command(const std::string &command, std::istream &parameters, std::istream &in, std::ostream &out) override
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
static void sleep(int seconds, std::ostream &out)
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(const std::string &command, std::istream &parameters, std::istream &in, std::ostream &out) override
Writable specialization of Client.