-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalConfiguration.h
63 lines (51 loc) · 1.48 KB
/
GlobalConfiguration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <cstddef>
#include "Page.h"
class GlobalConfiguration
{
public:
static const int MAGIC_SIZE = 5;
static const char MAGIC[MAGIC_SIZE];
GlobalConfiguration(
const size_t &desiredPageCount,
const size_t &desiredPageSize,
const size_t &desiredRootNodePageNumber,
const size_t &desiredCacheSize,
const char *desiredJournalPath
);
~GlobalConfiguration();
void initialize(
const size_t &pageCount,
const size_t &pageSize,
const size_t &rootNodePageNumber,
const size_t &cacheSize,
const char *journalPath
);
size_t desiredPageCount() const;
size_t desiredPageSize() const;
size_t desiredDatabaseSize() const;
size_t desiredRootNodePageNumber() const;
size_t desiredCacheSize() const;
char *desiredJournalPath() const;
size_t pageCount() const;
size_t pageSize() const;
size_t databaseSize() const;
size_t rootNodePageNumber() const;
size_t cacheSize() const;
char *journalPath() const;
void setRootNodePageNumber(const size_t &newRootNodePageNumber);
bool isReadedFromFile() const;
void readFromFile(int m_fd);
void skipDataOnPage(Page &page) const;
void writeToPage(Page &page) const;
private:
bool m_isInitialized;
size_t m_pageCount;
size_t m_pageSize;
size_t m_rootNodePageNumber;
size_t m_cacheSize;
char *m_journalPath;
bool m_isReadedFromFile;
GlobalConfiguration(GlobalConfiguration &) { };
void operator=(const GlobalConfiguration &) { };
};