Joedb 10.0.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Readonly_Client_h.cpp
Go to the documentation of this file.
3
4namespace joedb::generator
5{
6 ////////////////////////////////////////////////////////////////////////////
8 ////////////////////////////////////////////////////////////////////////////
9 (
10 const Compiler_Options &options
11 ):
12 Generator(".", "Readonly_Client.h", options)
13 {
14 }
15
16 ////////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////
19 {
21
22 out << R"RRR(
23#include "Database_Writable.h"
24#include "joedb/concurrency/Readonly_Client.h"
25
26)RRR";
27
29
30 out << R"RRR(
31 /// Client for a read-only file (allows pulling, unlike @ref Readonly_Database)
32 class Readonly_Client: private joedb::Connection, public joedb::Readonly_Client
33 {
34 private:
35 Database_Writable db;
36 int64_t schema_checkpoint;
37
38 protected:
39 virtual void read_journal() override
40 {
41 Readonly_Journal::play_until_checkpoint(db);
42 if (db.get_schema_checkpoint() > schema_checkpoint)
43 Database::throw_exception("Pulled a schema change");
44 }
45
46 public:
47 Readonly_Client(joedb::Buffered_File &file):
48 joedb::Readonly_Client
49 (
50 file,
51 *static_cast<joedb::Connection *>(this),
52 joedb::Content_Check::none
53 )
54 {
55 db.initialize_with_readonly_journal(*this);
56 schema_checkpoint = db.get_schema_checkpoint();
57 }
58
59 using joedb::Readonly_Client::pull;
60
61 const Database &get_database() const {return db;}
62 };
63)RRR";
64
65
67 out << "\n#endif\n";
68 }
69}
const std::vector< std::string > & get_name_space() const
const Compiler_Options & options
Definition Generator.h:14
Readonly_Client_h(const Compiler_Options &options)
void namespace_open(std::ostream &out, const std::vector< std::string > &n)
void namespace_close(std::ostream &out, const std::vector< std::string > &n)
void namespace_include_guard(std::ostream &out, const char *name, const std::vector< std::string > &n)
One code generator for each of the file generated by joedbc.
Definition Client_h.cpp:5