18 template<
typename Writable>
37 writable.set_start_index(1);
42 writable.set_start_index(0);
51#ifdef PERSISTENCE_TEST
52 class Joedb_Client:
public Readonly_Client
56 Writable_Journal writable;
62 Connection &connection,
63 Content_Check content_check,
66 Readonly_Client(file, connection, content_check, recovery),
67 data_file(
"joedb.joedb", Open_Mode::write_existing_or_create_new),
73 void read_journal()
override
75 this->data_journal.play_until_checkpoint(this->writable);
88 default_open_mode(default_open_mode),
89 default_db_type(default_db_type),
98 const bool hard_checkpoint = arguments.has_flag(
"hard_checkpoint");
100 static std::vector<const char *> check_string
109 arguments.get_enum_option
117 static std::vector<const char *> recovery_string
126 arguments.get_enum_option
134 static std::vector<const char *> db_string
142#ifdef PERSISTENCE_TEST
149 arguments.get_enum_option
157 arguments.add_parameter(
"<file>");
158 arguments.add_parameter(
"<connection>");
160 if (arguments.get_remaining_count() == 0)
163 std::cerr <<
"hard_checkpoint = " << hard_checkpoint <<
'\n';
164 std::cerr <<
"content_check = " << check_string[int(content_check)] <<
'\n';
165 std::cerr <<
"recovery = " << recovery_string[int(recovery)] <<
'\n';
166 std::cerr <<
"db_type = " << db_string[int(db_type)] <<
'\n';
169 Connection *connection = connection_parser.
build(arguments, client_file);
175 throw Exception(
"could not create file");
178 throw Exception(
"could not create connection");
180 std::cerr <<
"Creating client... ";
188 new Readonly_Client(*client_file, *connection, content_check, recovery)
257#ifdef PERSISTENCE_TEST
258 else if (db_type == DB_Type::joedb)
260 client.reset(
new Joedb_Client
Class for conveniently parsing command-line arguments.
bool is_readonly() const noexcept
Client_Parser(Open_Mode default_open_mode, DB_Type default_db_type, Arguments &arguments)
Connection * build(Arguments &arguments, Buffered_File *file) const
Buffered_File * parse(std::ostream &out, Arguments &arguments)
Specialized client for read-only files.
void play_until_checkpoint(Writable &writable)
void read_journal() override
Readonly_Writable_Client(Buffered_File &file, Connection &connection, bool tail, Content_Check content_check, Recovery recovery)
static const Record_Id null
Writable specialization of Client.
void set_hard_checkpoint(bool b)
Use hard checkpoints (default = false)
Superclass with all joedb journal event listeners as virtual functions.
@ read_existing
fails if does not exist
@ none
default: fail if file size > checkpoint