Joedb 9.6.2
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Writable_Database_Client.h
Go to the documentation of this file.
1#ifndef joedb_Writable_Database_Client_declared
2#define joedb_Writable_Database_Client_declared
3
6#include "joedb/Multiplexer.h"
7
8namespace joedb
9{
10 namespace detail
11 {
12 class Writable_Database_Client_Data
13 {
14 protected:
15 Writable_Journal data_journal;
16 Database database;
17 Multiplexer multiplexer;
18
19 public:
20 Writable_Database_Client_Data(Buffered_File &file, Record_Id max_record_id):
21 data_journal(file),
22 database(max_record_id),
23 multiplexer{database, data_journal}
24 {
25 }
26 };
27 };
28
29 /// @ingroup concurrency
31 protected detail::Writable_Database_Client_Data,
32 public Writable_Client
33 {
35
36 protected:
37 void read_journal() override
38 {
39 data_journal.play_until_checkpoint(database);
40 }
41
42 public:
44 (
45 Buffered_File &file,
47 Content_Check content_check = Content_Check::fast,
48 Record_Id max_record_id = Record_Id::null
49 ):
50 Writable_Database_Client_Data(file, max_record_id),
51 Writable_Client(data_journal, connection, content_check)
52 {
54 }
55
56 const Database &get_database() const
57 {
58 return database;
59 }
60
61 template<typename F> auto transaction(F transaction)
62 {
64 {
65 return transaction(database, multiplexer);
66 });
67 }
68 };
69
70 /// @ingroup concurrency
72 {
73 public:
78
79 const Readable &get_readable() const
80 {
81 return static_cast<Writable_Database_Client &>(client).database;
82 }
83
85 {
87 return static_cast<Writable_Database_Client &>(client).multiplexer;
88 }
89 };
90}
91
92#endif
Lock object that allows writing to a database managed by a joedb::Client.
Writable_Client & client
Connection & connection
Definition Client.h:16
static const Record_Id null
Definition index_types.h:44
Writable specialization of Client.
auto transaction(F transaction)
Writable_Database_Client_Lock(Writable_Database_Client &client)
Writable_Database_Client(Buffered_File &file, Connection &connection, Content_Check content_check=Content_Check::fast, Record_Id max_record_id=Record_Id::null)
Content_Check
Definition Connection.h:19
#define JOEDB_DEBUG_ASSERT(x)
assertion tested in debug mode
Definition assert.h:20
Definition Blob.h:7