Joedb 10.0.1
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 return writable.get_position();
89 }
90
91 void Selective_Writable::start_writing(int64_t position)
92 {
93 writable.start_writing(position);
94 }
95
96 void Selective_Writable::end_writing(int64_t position)
97 {
98 writable.end_writing(position);
99 }
100
102 {
103 writable.soft_checkpoint();
104 }
105
107 {
108 writable.hard_checkpoint();
109 }
110
111 //
112 // data events
113 //
115 {
116 if (mode & data)
117 writable.insert_into(table_id, record_id);
118 }
119
121 {
122 if (mode & data)
123 writable.delete_from(table_id, record_id);
124 }
125
127 (
128 Table_Id table_id,
129 Record_Id record_id,
130 size_t size
131 )
132 {
133 if (mode & data)
134 writable.insert_vector(table_id, record_id, size);
135 }
136
138 (
139 Table_Id table_id,
140 Record_Id record_id,
141 size_t size
142 )
143 {
144 if (mode & data)
145 writable.delete_vector(table_id, record_id, size);
146 }
147
148 #define TYPE_MACRO(type, return_type, type_id, R, W)\
149 void Selective_Writable::update_##type_id(Table_Id table_id,\
150 Record_Id record_id,\
151 Field_Id field_id,\
152 return_type value)\
153 {\
154 if (mode & data)\
155 writable.update_##type_id(table_id, record_id, field_id, value);\
156 }
157 #include "joedb/TYPE_MACRO.h"
158
160 {
161 blob_found = true;
162 }
163}
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 end_writing(int64_t position) override
void delete_vector(Table_Id table_id, Record_Id record_id, size_t size) override
Selective_Writable(Writable &writable, Mode mode)
void on_blob(Blob blob) override
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
int64_t get_position() const override
Superclass with all joedb journal event listeners as virtual functions.
Definition Writable.h:17
virtual void insert_vector(Table_Id table_id, Record_Id record_id, size_t size)=0
Definition Writable.cpp:33
virtual void insert_into(Table_Id table_id, Record_Id record_id)
Definition Writable.h:50
virtual void drop_table(Table_Id table_id)
Definition Writable.h:27
virtual void create_table(const std::string &name)
Definition Writable.h:26
virtual void hard_checkpoint()
Definition Writable.h:24
virtual void drop_field(Table_Id table_id, Field_Id field_id)
Definition Writable.h:36
virtual void rename_table(Table_Id table_id, const std::string &name)
Definition Writable.h:28
virtual void delete_vector(Table_Id table_id, Record_Id record_id, size_t size)=0
Definition Writable.cpp:44
virtual void soft_checkpoint()
Definition Writable.h:23
virtual void custom(const std::string &name)
Definition Writable.h:44
virtual void start_writing(int64_t position)
Definition Writable.h:20
virtual void add_field(Table_Id table_id, const std::string &name, Type type)
Definition Writable.h:31
virtual void delete_from(Table_Id table_id, Record_Id record_id)
Definition Writable.h:51
virtual void end_writing(int64_t position)
Definition Writable.h:21
virtual int64_t get_position() const
Definition Writable.h:19
virtual void comment(const std::string &comment)
Definition Writable.h:45
virtual void valid_data()
Definition Writable.h:47
virtual void rename_field(Table_Id table_id, Field_Id field_id, const std::string &name)
Definition Writable.h:38
virtual void timestamp(int64_t timestamp)
Definition Writable.h:46
Definition Blob.h:7