Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Selective_Writable.cpp
Go to the documentation of this file.
2
3namespace joedb
4{
5 ////////////////////////////////////////////////////////////////////////////
7 ////////////////////////////////////////////////////////////////////////////
8 writable(writable),
9 mode(mode),
10 blob_found(false)
11 {
12 }
13
14 //
15 // Schema events
16 //
17 void Selective_Writable::create_table(const std::string &name)
18 {
19 if (mode & schema)
20 writable.create_table(name);
21 }
22
24 {
25 if (mode & schema)
26 writable.drop_table(table_id);
27 }
28
30 const std::string &name)
31 {
32 if (mode & schema)
33 writable.rename_table(table_id, name);
34 }
35
37 const std::string &name,
38 Type type)
39 {
40 if (mode & schema)
41 writable.add_field(table_id, name, type);
42 }
43
45 Field_Id field_id)
46 {
47 if (mode & schema)
48 writable.drop_field(table_id, field_id);
49 }
50
52 Field_Id field_id,
53 const std::string &name)
54 {
55 if (mode & schema)
56 writable.rename_field(table_id, field_id, name);
57 }
58
59 void Selective_Writable::custom(const std::string &name)
60 {
61 if (mode & schema)
62 writable.custom(name);
63 }
64
65 //
66 // Informative events
67 //
68 void Selective_Writable::comment(const std::string &comment)
69 {
70 if (mode & information)
71 writable.comment(comment);
72 }
73
74 void Selective_Writable::timestamp(int64_t timestamp)
75 {
76 if (mode & information)
77 writable.timestamp(timestamp);
78 }
79
81 {
82 if (mode & information)
83 writable.valid_data();
84 }
85
87 {
88 writable.checkpoint(commit_level);
89 }
90
91 //
92 // data events
93 //
95 {
96 if (mode & data)
97 writable.insert_into(table_id, record_id);
98 }
99
101 Record_Id record_id,
102 size_t size)
103 {
104 if (mode & data)
105 writable.insert_vector(table_id, record_id, size);
106 }
107
109 {
110 if (mode & data)
111 writable.delete_from(table_id, record_id);
112 }
113
114 #define TYPE_MACRO(type, return_type, type_id, R, W)\
115 void Selective_Writable::update_##type_id(Table_Id table_id,\
116 Record_Id record_id,\
117 Field_Id field_id,\
118 return_type value)\
119 {\
120 if (mode & data)\
121 writable.update_##type_id(table_id, record_id, field_id, value);\
122 }
123 #include "joedb/TYPE_MACRO.h"
124
126 {
127 blob_found = true;
128 }
129}
void drop_field(Table_Id table_id, Field_Id field_id) override
void add_field(Table_Id table_id, const std::string &name, Type type) override
void rename_field(Table_Id table_id, Field_Id field_id, const std::string &name) override
void insert_into(Table_Id table_id, Record_Id record_id) override
void comment(const std::string &comment) override
void custom(const std::string &name) override
void delete_from(Table_Id table_id, Record_Id record_id) override
void on_blob(Blob blob) final
void checkpoint(Commit_Level commit_level) override
Selective_Writable(Writable &writable, Mode mode)
void drop_table(Table_Id table_id) override
void rename_table(Table_Id table_id, const std::string &name) override
void create_table(const std::string &name) override
void timestamp(int64_t timestamp) override
void insert_vector(Table_Id table_id, Record_Id record_id, size_t size) override
virtual void insert_into(Table_Id table_id, Record_Id record_id)
Definition Writable.h:60
virtual void drop_table(Table_Id table_id)
Definition Writable.h:33
virtual void create_table(const std::string &name)
Definition Writable.h:32
virtual void drop_field(Table_Id table_id, Field_Id field_id)
Definition Writable.h:42
virtual void rename_table(Table_Id table_id, const std::string &name)
Definition Writable.h:34
virtual void insert_vector(Table_Id table_id, Record_Id record_id, size_t size)
Definition Writable.h:62
virtual void custom(const std::string &name)
Definition Writable.h:50
virtual void add_field(Table_Id table_id, const std::string &name, Type type)
Definition Writable.h:37
virtual void delete_from(Table_Id table_id, Record_Id record_id)
Definition Writable.h:67
virtual void checkpoint(Commit_Level commit_level)
Definition Writable.h:55
virtual void comment(const std::string &comment)
Definition Writable.h:51
virtual void valid_data()
Definition Writable.h:53
virtual void rename_field(Table_Id table_id, Field_Id field_id, const std::string &name)
Definition Writable.h:44
virtual void timestamp(int64_t timestamp)
Definition Writable.h:52
Definition Blob.h:7
Commit_Level
Definition Writable.h:13