Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Writable_Database.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2//
3// This code was automatically generated by the joedb compiler
4// https://www.joedb.org/
5//
6// Path to compiler: /home/rcoulom/repos/joedb/compcmake/gcc_debug/joedbc
7// Version: 10.2.1
8// joedbc compilation time: Sep 15 2025 20:22:33
9// Generation of this file: 2025-09-15 18:23:01 GMT
10//
11/////////////////////////////////////////////////////////////////////////////
12#ifndef tutorial_rpc_city_Writable_Database_declared
13#define tutorial_rpc_city_Writable_Database_declared
14
15#include "Database_Writable.h"
16
17namespace tutorial::rpc::city
18{
19 namespace detail
20 {
21 class Client_Data;
22 }
23
24 class Client;
25 class Multiplexer;
26 class Memory_Database;
27
28 /// A @ref Database that contains a @ref joedb::Writable_Journal and keeps them in sync
30 {
31 friend class detail::Client_Data;
32 friend class Client;
33 friend class Multiplexer;
34 friend class Memory_Database;
35
36 private:
38 bool ready_to_write;
39
40 void play_journal();
41 void auto_upgrade();
42 void check_single_row();
43 void initialize();
44
45 void create_table(const std::string &name) override;
46
48 (
50 joedb::Recovery recovery,
51 bool perform_initialization
52 );
53
54 public:
56
58 (
60 joedb::Recovery recovery
61 );
62
63 const joedb::Readonly_Journal &get_journal() const {return journal;}
64
65 std::string read_blob(joedb::Blob blob) const
66 {
67 return journal.get_file().read_blob(blob);
68 }
69
70 joedb::Blob write_blob(const std::string &data) override
71 {
72 return journal.write_blob(data);
73 }
74
75 int64_t ahead_of_checkpoint() const
76 {
77 return journal.ahead_of_checkpoint();
78 }
79
80 void soft_checkpoint() override
81 {
82 journal.soft_checkpoint();
83 }
84
85 void hard_checkpoint() override
86 {
87 journal.hard_checkpoint();
88 }
89
90 void write_comment(const std::string &comment);
91 void write_timestamp();
92 void write_timestamp(int64_t timestamp);
93 void write_valid_data();
94 void flush() override {journal.flush();}
95
96 private:
97 id_of_city new_city()
98 {
99 id_of_city result(Record_Id(storage_of_city.freedom_keeper.get_free_record()));
100 storage_of_city.resize(storage_of_city.freedom_keeper.size());
101 internal_insert_city(result.get_record_id());
102
103 journal.insert_into(Table_Id(1), result.get_record_id());
104 return result;
105 }
106
107 id_of_city new_city
108 (
109 const std::string& field_value_of_name
110 )
111 {
112 auto result = new_city();
113 set_name(result, field_value_of_name);
114 return result;
115 }
116
117 public:
118 void set_name(id_of_city record, const std::string& field_value_of_name)
119 {
120 internal_update_city__name(record.get_record_id(), field_value_of_name);
121 journal.update_string(Table_Id(1), record.get_record_id(), Field_Id(1), field_value_of_name);
122 }
123
124 void set_name(const std::string& field_value_of_name)
125 {
126 set_name(the_city(), field_value_of_name);
127 }
128
129
130 };}
131
132#endif
std::string read_blob(Blob blob) const
const Abstract_File & get_file() const
int64_t ahead_of_checkpoint() const noexcept
void insert_into(Table_Id table_id, Record_Id record_id) override
Blob write_blob(const std::string &data) override
Strongly-typed wrapper around an integer representing a row of the city table.
Definition ids.h:25
constexpr Record_Id get_record_id() const
Definition ids.h:36
Handle concurrent access to a joedb::Abstract_File using a joedb::Connection.
Definition Client.h:44
implement joedb::Writable in a Database
void timestamp(int64_t timestamp) override
void comment(const std::string &comment) override
void internal_insert_city(Record_Id record_id)
Definition Database.h:87
void internal_update_city__name(Record_Id record_id, const std::string &field_value_of_name)
Definition Database.h:99
static constexpr id_of_city the_city()
Definition Database.h:144
detail::data_of_city storage_of_city
Definition Database.h:77
Shortcut to directly build a Writable_Database with a Memory_File.
Write simultaneously to the database and the file (ignore schema changes)
Definition Multiplexer.h:40
A Database that contains a joedb::Writable_Journal and keeps them in sync.
std::string read_blob(joedb::Blob blob) const
void set_name(id_of_city record, const std::string &field_value_of_name)
joedb::Blob write_blob(const std::string &data) override
void set_name(const std::string &field_value_of_name)
const joedb::Readonly_Journal & get_journal() const
void write_comment(const std::string &comment)
Automatically generated by joedbc.
Definition Client.h:19