-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathFileDataSource.hpp
More file actions
188 lines (161 loc) · 7.55 KB
/
Copy pathFileDataSource.hpp
File metadata and controls
188 lines (161 loc) · 7.55 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
* Alicia Server - dedicated server software
* Copyright (C) 2024 Story Of Alicia
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef FILEDATASOURCE_HPP
#define FILEDATASOURCE_HPP
#include <libserver/data/DataDefinitions.hpp>
#include <libserver/data/DataSource.hpp>
namespace server
{
class FileDataSource
: public DataSource
{
public:
~FileDataSource() override = default;
void Initialize(const std::filesystem::path& path);
void Terminate();
void SaveMetadata();
void CreateUser(data::User& user) override;
void RetrieveUser(const std::string_view& name, data::User& user) override;
void StoreUser(const std::string_view& name, const data::User& user) override;
bool IsUserNameUnique(const std::string_view& name) override;
void CreateInfraction(data::Infraction& infraction) override;
void RetrieveInfraction(data::Uid uid, data::Infraction& infraction) override;
void StoreInfraction(data::Uid uid, const data::Infraction& infraction) override;
void DeleteInfraction(data::Uid uid) override;
void CreateCharacter(data::Character& character) override;
void RetrieveCharacter(data::Uid uid, data::Character& character) override;
void StoreCharacter(data::Uid uid, const data::Character& character) override;
void DeleteCharacter(data::Uid uid) override;
data::Uid RetrieveCharacterUidByName(const std::string_view& name) override;
bool IsCharacterNameUnique(const std::string_view& name) override;
void CreateHorse(data::Horse& horse) override;
void RetrieveHorse(data::Uid uid, data::Horse& horse) override;
void StoreHorse(data::Uid uid, const data::Horse& horse) override;
void DeleteHorse(data::Uid uid) override;
void CreateItem(data::Item& item) override;
void RetrieveItem(data::Uid uid, data::Item& item) override;
void StoreItem(data::Uid uid, const data::Item& item) override;
void DeleteItem(data::Uid uid) override;
void CreateStorageItem(data::StorageItem& storageItem) override;
void RetrieveStorageItem(data::Uid uid, data::StorageItem& storageItem) override;
void StoreStorageItem(data::Uid uid, const data::StorageItem& storageItem) override;
void DeleteStorageItem(data::Uid uid) override;
void CreateEgg(data::Egg& egg) override;
void RetrieveEgg(data::Uid uid, data::Egg& egg) override;
void StoreEgg(data::Uid uid, const data::Egg& egg) override;
void DeleteEgg(data::Uid uid) override;
void CreatePet(data::Pet& pet) override;
void RetrievePet(data::Uid uid, data::Pet& pet) override;
void StorePet(data::Uid uid, const data::Pet& pet) override;
void DeletePet(data::Uid uid) override;
void CreateHousing(data::Housing& housing) override;
void RetrieveHousing(data::Uid uid, data::Housing& housing) override;
void StoreHousing(data::Uid uid, const data::Housing& housing) override;
void DeleteHousing(data::Uid uid) override;
void CreateGuild(data::Guild& guild) override;
void RetrieveGuild(data::Uid uid, data::Guild& guild) override;
void StoreGuild(data::Uid uid, const data::Guild& guild) override;
void DeleteGuild(data::Uid uid) override;
bool IsGuildNameUnique(const std::string_view& name) override;
void CreateSettings(data::Settings& settings) override;
void RetrieveSettings(data::Uid uid, data::Settings& settings) override;
void StoreSettings(data::Uid uid, const data::Settings& settings) override;
void DeleteSettings(data::Uid uid) override;
void CreateDailyQuestGroup(data::DailyQuestGroup& group) override;
void RetrieveDailyQuestGroup(data::Uid uid, data::DailyQuestGroup& group) override;
void StoreDailyQuestGroup(data::Uid uid, const data::DailyQuestGroup& group) override;
void DeleteDailyQuestGroup(data::Uid uid) override;
void CreateMail(data::Mail& mail) override;
void RetrieveMail(data::Uid uid, data::Mail& mail) override;
void StoreMail(data::Uid uid, const data::Mail& mail) override;
void DeleteMail(data::Uid uid) override;
void CreateQuest(data::Quest& quest) override;
void RetrieveQuest(data::Uid uid, data::Quest& quest) override;
void StoreQuest(data::Uid uid, const data::Quest& quest) override;
void DeleteQuest(data::Uid uid) override;
void CreateStallion(data::Stallion& stallion) override;
void RetrieveStallion(data::Uid uid, data::Stallion& stallion) override;
void StoreStallion(data::Uid uid, const data::Stallion& stallion) override;
void DeleteStallion(data::Uid uid) override;
std::vector<data::Uid> ListRegisteredStallions() override;
private:
//! A root data path.
std::filesystem::path _dataPath;
//! A path to the user data files.
std::filesystem::path _userDataPath;
//! A path to the infraction data files.
std::filesystem::path _infractionDataPath;
//! A path to the character data files.
std::filesystem::path _characterDataPath;
//! A path to the horse data files.
std::filesystem::path _horseDataPath;
//! A path to the item data files.
std::filesystem::path _itemDataPath;
//! A path to the egg data files.
std::filesystem::path _eggDataPath;
//! A path to the stored item data files.
std::filesystem::path _storageItemPath;
//! A path to the pet data files.
std::filesystem::path _petDataPath;
//! A path to the housing data files.
std::filesystem::path _housingDataPath;
//! A path to the guild data files.
std::filesystem::path _guildDataPath;
//! A path to the settings data files.
std::filesystem::path _settingsDataPath;
//! A path to the daily quest group data files.
std::filesystem::path _dailyQuestGroupDataPath;
//! A path to the mail data files.
std::filesystem::path _mailDataPath;
//! A path to the quest data files.
std::filesystem::path _questDataPath;
//! A path to the stallion data files.
std::filesystem::path _stallionDataPath;
//! A path to meta-data file.
std::filesystem::path _metaFilePath;
//! Sequential UID for infractions.
std::atomic_uint32_t _infractionSequentialUid = 0;
//! Sequential UID for characters.
std::atomic_uint32_t _characterSequentialUid = 0;
//! Sequential UID pool for equipment.
//! Equipment includes items and horses.
std::atomic_uint32_t _equipmentSequentialUid = 0;
//! Sequential UID for storage items.
std::atomic_uint32_t _storageItemSequentialUid = 0;
//! Sequential UID for eggs.
std::atomic_uint32_t _eggSequentialUid = 0;
//! Sequential UID for pets.
std::atomic_uint32_t _petSequentialUid = 0;
//! Sequential UID for housing.
std::atomic_uint32_t _housingSequentialUid = 0;
//! Sequential UID for guilds.
std::atomic_uint32_t _guildSequentialId = 0;
//! Sequential UID for settings.
std::atomic_uint32_t _settingsSequentialId = 0;
//! Sequential UID for daily quest groups.
std::atomic_uint32_t _dailyQuestGroupSequentialId = 0;
//! Sequential UID for mail.
std::atomic_uint32_t _mailSequentialId = 0;
//! Sequential UID for quests.
std::atomic_uint32_t _questSequentialId = 0;
//! Sequential UID for stallions.
std::atomic_uint32_t _stallionSequentialUid = 0;
};
} // namespace server
#endif // FILEDATASOURCE_HPP