Joedb 9.5.0
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
86 void Selective_Writable::start_writing(int64_t position)
87 {
88 writable.start_writing(position);
89 }
90
92 {
93 return writable.get_position();
94 }
95
97 {
98 writable.soft_checkpoint_at(position);
99 }
100
102 {
103 writable.hard_checkpoint_at(position);
104 }
105
106 //
107 // data events
108 //
110 {
111 if (mode & data)
112 writable.insert_into(table_id, record_id);
113 }
114
116 {
117 if (mode & data)
118 writable.delete_from(table_id, record_id);
119 }
120
122 (
123 Table_Id table_id,
124 Record_Id record_id,
125 size_t size
126 )
127 {
128 if (mode & data)
129 writable.insert_vector(table_id, record_id, size);
130 }
131
133 (
134 Table_Id table_id,
135 Record_Id record_id,
136 size_t size
137 )
138 {
139 if (mode & data)
140 writable.delete_vector(table_id, record_id, size);
141 }
142
143 #define TYPE_MACRO(type, return_type, type_id, R, W)\
144 void Selective_Writable::update_##type_id(Table_Id table_id,\
145 Record_Id record_id,\
146 Field_Id field_id,\
147 return_type value)\
148 {\
149 if (mode & data)\
150 writable.update_##type_id(table_id, record_id, field_id, value);\
151 }
152 #include "joedb/TYPE_MACRO.h"
153
155 {
156 blob_found = true;
157 }
158}
void drop_field(Table_Id table_id, Field_Id field_id) override
void start_writing(int64_t position) 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 delete_vector(Table_Id table_id, Record_Id record_id, size_t size) override
void soft_checkpoint_at(int64_t position) 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 hard_checkpoint_at(int64_t position) 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
int64_t get_position() const override
virtual void insert_into(Table_Id table_id, Record_Id record_id)
Definition Writable.h:48
virtual void drop_table(Table_Id table_id)
Definition Writable.h:25
virtual void create_table(const std::string &name)
Definition Writable.h:24
virtual void hard_checkpoint_at(int64_t position)
Definition Writable.h:17
virtual void drop_field(Table_Id table_id, Field_Id field_id)
Definition Writable.h:34
virtual void rename_table(Table_Id table_id, const std::string &name)
Definition Writable.h:26
virtual void insert_vector(Table_Id table_id, Record_Id record_id, size_t size)
Definition Writable.cpp:33
virtual void custom(const std::string &name)
Definition Writable.h:42
virtual void start_writing(int64_t position)
Definition Writable.h:15
virtual void delete_vector(Table_Id table_id, Record_Id record_id, size_t size)
Definition Writable.cpp:44
virtual void add_field(Table_Id table_id, const std::string &name, Type type)
Definition Writable.h:29
virtual void delete_from(Table_Id table_id, Record_Id record_id)
Definition Writable.h:49
virtual void soft_checkpoint_at(int64_t position)
Definition Writable.h:16
virtual int64_t get_position() const
Definition Writable.h:14
virtual void comment(const std::string &comment)
Definition Writable.h:43
virtual void valid_data()
Definition Writable.h:45
virtual void rename_field(Table_Id table_id, Field_Id field_id, const std::string &name)
Definition Writable.h:36
virtual void timestamp(int64_t timestamp)
Definition Writable.h:44
Definition Blob.h:7