TrinityCore
Loading...
Searching...
No Matches
DatabaseLoader.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef DatabaseLoader_h__
19
#define DatabaseLoader_h__
20
21
#include "
Define.h
"
22
23
#include <functional>
24
#include <queue>
25
#include <stack>
26
#include <string>
27
28
template
<
class
T>
29
class
DatabaseWorkerPool
;
30
31
// A helper class to initiate all database worker pools,
32
// handles updating, delays preparing of statements and cleans up on failure.
33
class
TC_DATABASE_API
DatabaseLoader
34
{
35
public
:
36
DatabaseLoader
(std::string
const
& logger,
uint32
const
defaultUpdateMask);
37
38
// Register a database to the loader (lazy implemented)
39
template
<
class
T>
40
DatabaseLoader
& AddDatabase(
DatabaseWorkerPool<T>
& pool, std::string
const
& name);
41
42
// Load all databases
43
bool
Load();
44
45
enum
DatabaseTypeFlags
46
{
47
DATABASE_NONE = 0,
48
49
DATABASE_LOGIN = 1,
50
DATABASE_CHARACTER = 2,
51
DATABASE_WORLD = 4,
52
DATABASE_HOTFIX = 8,
53
54
DATABASE_MASK_ALL = DATABASE_LOGIN | DATABASE_CHARACTER | DATABASE_WORLD | DATABASE_HOTFIX
55
};
56
57
private
:
58
bool
OpenDatabases();
59
bool
PopulateDatabases();
60
bool
UpdateDatabases();
61
bool
PrepareStatements();
62
63
using
Predicate
= std::function<bool()>;
64
using
Closer
= std::function<void()>;
65
66
// Invokes all functions in the given queue and closes the databases on errors.
67
// Returns false when there was an error.
68
bool
Process
(std::queue<Predicate>& queue);
69
70
std::string
const
_logger
;
71
bool
const
_autoSetup
;
72
uint32
const
_updateFlags
;
73
74
std::queue<Predicate>
_open
, _populate, _update, _prepare;
75
std::stack<Closer>
_close
;
76
};
77
78
#endif
// DatabaseLoader_h__
DB2EncryptedSectionHandling::Process
@ Process
Define.h
TC_DATABASE_API
#define TC_DATABASE_API
Definition
Define.h:111
uint32
uint32_t uint32
Definition
Define.h:154
DatabaseLoader
Definition
DatabaseLoader.h:34
DatabaseLoader::_logger
std::string const _logger
Definition
DatabaseLoader.h:70
DatabaseLoader::_autoSetup
bool const _autoSetup
Definition
DatabaseLoader.h:71
DatabaseLoader::DatabaseTypeFlags
DatabaseTypeFlags
Definition
DatabaseLoader.h:46
DatabaseLoader::Closer
std::function< void()> Closer
Definition
DatabaseLoader.h:64
DatabaseLoader::_updateFlags
uint32 const _updateFlags
Definition
DatabaseLoader.h:72
DatabaseLoader::Predicate
std::function< bool()> Predicate
Definition
DatabaseLoader.h:63
DatabaseLoader::_open
std::queue< Predicate > _open
Definition
DatabaseLoader.h:74
DatabaseLoader::_close
std::stack< Closer > _close
Definition
DatabaseLoader.h:75
DatabaseWorkerPool
Definition
DatabaseWorkerPool.h:34
server
database
Database
DatabaseLoader.h
Generated on Sun May 10 2026 02:08:51 for TrinityCore by
1.9.8