-
Notifications
You must be signed in to change notification settings - Fork 0
/
vogal_handler.cc
93 lines (74 loc) · 1.96 KB
/
vogal_handler.cc
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "vogal_handler.h"
vogal_handler::vogal_handler(){
DBUG_ENTER("vogal_handler::vogal_handler");
m_Cache = new vogal_cache(this);
m_Storage = new vogal_storage(this);
m_Definition = new vogal_definition(this);
m_Manipulation = new vogal_manipulation(this);
printf("INICIALIZANDO STORAGE ENGINE VOGAL!\n");
if (!ensureSanity())
my_error(ER_UNKNOWN_ERROR, MYF(0), "Erro ao testar a sanidade do arquivo de dados!");
printf("STORAGE ENGINE VOGAL INICIALIZADO!\n");
DBUG_LEAVE;
}
vogal_handler::~vogal_handler(){
DBUG_ENTER("vogal_handler::~vogal_handler");
if (m_Storage) {
m_Storage->~vogal_storage();
m_Storage = NULL;
}
if (m_Cache) {
m_Cache->~vogal_cache();
m_Cache = NULL;
}
if (m_Definition) {
m_Definition->~vogal_definition();
m_Definition = NULL;
}
if (m_Manipulation) {
m_Manipulation->~vogal_manipulation();
m_Manipulation = NULL;
}
DBUG_LEAVE;
}
vogal_cache* vogal_handler::getCache() {
DBUG_ENTER("vogal_handler::getCache");
DBUG_RETURN(m_Cache);
}
vogal_storage* vogal_handler::getStorage() {
DBUG_ENTER("vogal_handler::getStorage");
DBUG_RETURN(m_Storage);
}
vogal_definition* vogal_handler::getDefinition() {
DBUG_ENTER("vogal_handler::getDefinition");
DBUG_RETURN(m_Definition);
}
vogal_manipulation* vogal_handler::getManipulation() {
DBUG_ENTER("vogal_handler::getManipulation");
DBUG_RETURN(m_Manipulation);
}
int vogal_handler::ensureSanity() {
DBUG_ENTER("vogal_handler::ensureSanity");
bool newDatabase = false;
bool notOpened = !getStorage()->isOpen();
if (!getStorage()->openDatabase()) {
if (getStorage()->initialize()) {
newDatabase = true;
} else {
ERROR("Erro ao criar DB");
DBUG_RETURN(false);
}
}
if (notOpened) {
if (!getCache()->bufferize()) {
ERROR("Erro ao bufferizar DB");
DBUG_RETURN(false);
}
if (newDatabase)
if (!getDefinition()->createDataDictionary()) {
ERROR("Erro ao criar dicionário de dados");
DBUG_RETURN(false);
}
}
DBUG_RETURN(true);
}