18 template<
typename Writable_Multiplexer>
22 Writable_Multiplexer writable_multiplexer;
34 writable_multiplexer(std::cout)
37 writable_multiplexer.set_start_index(1);
42 writable_multiplexer.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);
89 default_open_mode(default_open_mode),
90 default_db_type(default_db_type),
99 const bool hard_checkpoint = arguments.has_flag(
"hard_checkpoint");
101 static std::vector<const char *> check_string
110 arguments.get_enum_option
118 static std::vector<const char *> recovery_string
127 arguments.get_enum_option
135 static std::vector<const char *> db_string
143#ifdef PERSISTENCE_TEST
150 arguments.get_enum_option
158 arguments.add_parameter(
"<file>");
159 arguments.add_parameter(
"<connection>");
161 if (arguments.get_remaining_count() == 0)
164 logger.log(
"hard_checkpoint = " + std::to_string(hard_checkpoint));
165 logger.log(
"content_check = " + std::string(check_string[
int(content_check)]));
166 logger.log(
"recovery = " + std::string(recovery_string[
int(recovery)]));
167 logger.log(
"db_type = " + std::string(db_string[
int(db_type)]));
170 Connection *connection = connection_parser.
build(logger, arguments, client_file);
176 throw Exception(
"could not create file");
179 throw Exception(
"could not create connection");
181 logger.log(
"creating client");
189 new Readonly_Client(*client_file, *connection, content_check, recovery)
258#ifdef PERSISTENCE_TEST
259 else if (db_type == DB_Type::joedb)
261 client.reset(
new Joedb_Client
bool is_readonly() const noexcept
Class for conveniently parsing command-line arguments.
Client_Parser(Logger &logger, Open_Mode default_open_mode, DB_Type default_db_type, Arguments &arguments)
Connection * build(Logger &logger, Arguments &arguments, Abstract_File *file) const
Abstract_File * parse(joedb::Logger &log, Arguments &arguments)
Specialized client for read-only files.
void play_until_checkpoint(Writable &writable)
Readonly_Writable_Client(Abstract_File &file, Connection &connection, bool tail, Content_Check content_check, Recovery recovery)
void read_journal() override
static const Record_Id null
Writable specialization of Client.
void set_hard_checkpoint(bool b)
Use hard checkpoints (default = false)
@ read_existing
fails if does not exist
@ none
default: fail if file size > checkpoint