xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
TableManager.h
Go to the documentation of this file.
1#ifndef TABLE_MANAGER_H
2#define TABLE_MANAGER_H
3
8
9#include <cstring>
10#include <fstream>
11
12#include <memory>
13
14namespace Xale::Execution
15{
20 {
21 public:
28
34 Xale::DataStructure::Table* createTable(const std::string& name);
35
41 bool dropTable(const std::string& name);
42
48 Xale::DataStructure::Table* getTable(const std::string& name);
49
55 bool tableExists(const std::string& name) const;
56
61 std::vector<std::string> getTableNames() const;
62
73 void saveAllTables();
74
85 void loadAllTables();
86
87 private:
89 Xale::Storage::IFileManager& _fileManager;
90 std::unordered_map<std::string, std::unique_ptr<Xale::DataStructure::Table>> _tables;
91
96 void saveTable(const Xale::DataStructure::Table& table);
97
103 void loadTable(const std::string& tableName, const std::vector<char>& data);
104 };
105}
106
107#endif // TABLE_MANAGER_H
Represents a mutable and persistent dataset (table).
Definition Table.h:19
bool tableExists(const std::string &name) const
Checks if a table with the given name exists.
Definition TableManager.cpp:46
Xale::DataStructure::Table * createTable(const std::string &name)
Creates a new table with the given name.
Definition TableManager.cpp:11
std::vector< std::string > getTableNames() const
Retrieves the names of all existing tables.
Definition TableManager.cpp:51
bool dropTable(const std::string &name)
Drops the table with the given name.
Definition TableManager.cpp:25
TableManager(Xale::Storage::IStorageEngine &storage, Xale::Storage::IFileManager &fileManager)
Constructor for TableManager.
Definition TableManager.cpp:5
Xale::DataStructure::Table * getTable(const std::string &name)
Retrieves the table with the given name.
Definition TableManager.cpp:36
void saveAllTables()
Save all tables to disk File format: [4 bytes: table_count] For each table: [4 bytes: table_name_leng...
Definition TableManager.cpp:61
void loadAllTables()
Load all tables from disk File format: [4 bytes: table_count] For each table: [4 bytes: table_name_le...
Definition TableManager.cpp:118
Interface for file management operations.
Definition IFileManager.h:13
Interface for storage engine operations.
Definition IStorageEngine.h:12
Definition BasicExecutor.h:13