mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
TableFactory.cpp
Go to the documentation of this file.
2
4
5
6using namespace m;
7
8
9namespace {
10
11
12__attribute__((constructor(201)))
13void add_table_args()
14{
15 Catalog &C = Catalog::Get();
16
17 /*----- Command-line arguments -----*/
18 // TODO add "multi-versioning" to default when multi-versioning support is complete.
19 C.arg_parser().add<std::vector<std::string_view>>(
20 /* group= */ "TableFactory",
21 /* short= */ nullptr,
22 /* long= */ "--table-properties",
23 /* description= */ "enable multiple table properties.",
24 /* callback= */ [](std::vector<std::string_view> properties) {
25 Catalog &C = Catalog::Get();
26 std::unique_ptr<TableFactory> table_factory = std::make_unique<ConcreteTableFactory>();
27 for (auto property : properties)
28 table_factory = C.apply_table_property(C.pool(property), std::move(table_factory));
29 C.table_factory(std::move(table_factory));
30 }
31 );
32}
33
34
35}
36
37
38__attribute__((constructor(202)))
39void register_table_factories()
40{
41 Catalog &C = Catalog::Get();
42
43 std::unique_ptr<TableFactory> table_factory = std::make_unique<ConcreteTableFactory>();
44 C.table_factory(std::move(table_factory));
45
47 "enables multi-versioning");
48}
__attribute__((constructor(202))) void register_table_factories()
void add(const char *group_name, const char *short_name, const char *long_name, const char *description, Callback &&callback)
Adds a new group option to the ArgParser.
Definition: ArgParser.hpp:84
‍mutable namespace
Definition: Backend.hpp:10
The catalog contains all Databases and keeps track of all meta information of the database system.
Definition: Catalog.hpp:215
std::unique_ptr< TableFactory > apply_table_property(const ThreadSafePooledString &name, std::unique_ptr< TableFactory > table_factory) const
Applies the TableFactoryDecorator corresponding to name to table_factory.
Definition: Catalog.hpp:595
ThreadSafePooledString pool(const char *str) const
Creates an internalized copy of the string str by adding it to the internal StringPool.
Definition: Catalog.hpp:274
void register_table_property(ThreadSafePooledString name, const char *description=nullptr)
Registers a new TableFactoryDecorator with the given name.
Definition: Catalog.hpp:582
static Catalog & Get()
Return a reference to the single Catalog instance.
m::ArgParser & arg_parser()
Definition: Catalog.hpp:253
std::unique_ptr< TableFactory > table_factory(std::unique_ptr< TableFactory > table_factory)
Replaces the stored TableFactory with table_factory and returns the old TableFactory.
Definition: Catalog.hpp:572