LeviLamina
Loading...
Searching...
No Matches
LevelListCache.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/minecraft/threading/EnableQueueForMainThread.h"
8#include "mc/deps/core/utility/NonOwnerPointer.h"
9#include "mc/deps/core/utility/SingleThreadedLock.h"
10#include "mc/deps/core/utility/Subject.h"
11#include "mc/deps/core/utility/UniqueOwnerPointer.h"
12#include "mc/platform/threading/LockGuard.h"
13#include "mc/world/level/LevelListCacheObserver.h"
14#include "mc/world/level/storage/ILevelListCache.h"
15
16// auto generated forward declare list
17// clang-format off
18class AppPlatform;
19class ContentIdentity;
21class LevelCache;
22class LevelData;
23class LevelDbEnv;
26class LevelStorage;
30class Scheduler;
31struct LevelSummary;
32namespace Core { class Path; }
33// clang-format on
34
36public:
37 // LevelListCache inner types define
38 using LevelAddedType = ::LevelListCacheObserver::LevelAddedType;
39
41
42public:
43 // member variables
44 // NOLINTBEGIN
45 ::ll::TypedStorage<8, 8, ::LevelStorageSource&> mLevelStorageSource;
46 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::LevelCache>> mCachedLevelData;
47 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::LevelSummary>> mCachedUnSyncedLevelData;
48 ::ll::TypedStorage<1, 1, bool> mDiscoverLevels;
49 ::ll::TypedStorage<8, 32, ::Core::Subject<::LevelListCacheObserver, ::Core::SingleThreadedLock>> mSubject;
50 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mCacheLock;
51 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const> const> mAppPlatform;
52 ::ll::TypedStorage<8, 64, ::std::function<bool()>> mCheckIsSafeToFlushCache;
53 // NOLINTEND
54
55public:
56 // prevent constructor by default
57 LevelListCache& operator=(LevelListCache const&);
58 LevelListCache(LevelListCache const&);
59 LevelListCache();
60
61public:
62 // virtual functions
63 // NOLINTBEGIN
64 virtual ~LevelListCache() /*override*/ = default;
65
66 virtual void addLevel(::std::string const& levelId, ::LevelData&& levelData) /*override*/;
67
68 virtual void deleteLevel(::std::string const& levelId) /*override*/;
69
70 virtual void refreshLevel(::std::string const& levelId) /*override*/;
71
72 virtual void ensureLevelInitialized(::std::string const& levelId) /*override*/;
73
74 virtual void deleteLevelFiles(::std::string const& levelId) /*override*/;
75
76 virtual void postDeleteLevel(::std::string const& levelId) /*override*/;
77
78 virtual void renameLevel(::std::string const& levelId, ::std::string const& newLevelName) /*override*/;
79
80 virtual void renameAndSaveLevelData(
81 ::std::string const& levelId,
82 ::std::string const& newLevelName,
83 ::LevelData const& levelData
84 ) /*override*/;
85
86 virtual void saveLevelData(::std::string const& levelId, ::LevelData const& levelData) /*override*/;
87
88 virtual void createBackupCopyOfWorld(
89 ::std::string const& levelId,
90 ::std::string const& newLevelId,
91 ::std::string const& newName
92 ) /*override*/;
93
94 virtual bool hasLevelWithId(::std::string const& levelId) /*override*/;
95
96 virtual ::std::string getLevelIdFromPath(::Core::Path const& fullPath, ::Core::Path const& worldsPath) /*override*/;
97
98 virtual bool checkIfLevelIsCorruptOrMissing(::std::string const& levelId) /*override*/;
99
100 virtual void addObserver(::LevelListCacheObserver& observer) /*override*/;
101
102 virtual void removeObserver(::LevelListCacheObserver& observer) /*override*/;
103
104 virtual ::Bedrock::UniqueOwnerPointer<::LevelStorage> createLevelStorage(
105 ::Scheduler& scheduler,
106 ::std::string const& levelId,
107 ::ContentIdentity const& contentIdentity,
108 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider,
109 ::std::chrono::nanoseconds const& writeFlushInterval,
110 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
111 ::std::unique_ptr<::LevelStorageEventing> levelStorageEventing
112 ) /*override*/;
113
114 virtual ::std::unique_ptr<::LevelLooseFileStorage> createLevelLooseStorage(
115 ::std::string const& levelId,
116 ::ContentIdentity const& contentIdentity,
117 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider
118 ) /*override*/;
119
120 virtual ::LevelSummary* getLevelSummary(::std::string const& levelId) /*override*/;
121
122 virtual ::LevelSummary const* getLevelSummaryByName(::std::string const& levelName) /*override*/;
123
124 virtual ::LevelSummary* getOrCreateLevelSummary(::Core::Path const& directory) /*override*/;
125
126 virtual ::LevelData* getLevelData(::std::string const& levelId) /*override*/;
127
128 virtual ::Bedrock::NonOwnerPointer<::LevelData>
129 getLevelDataNonOwnerPointer(::std::string const& levelId) /*override*/;
130
131 virtual ::LevelSummary* getShallowLevelSummary(::std::string const& levelId) /*override*/;
132
133 virtual void getLevelList(
134 ::std::vector<::LevelSummary>& dest,
135 bool includeShallowSummaries,
136 bool includePartiallyCopiedLevels,
137 bool includeBetaRetailLevels,
138 bool includeInvalidLevelDataLevels
139 ) /*override*/;
140
141 virtual bool hasCachedLevels(bool includeShallowSummaries) const /*override*/;
142
143 virtual void updateLevelCache(::std::string const& levelId) /*override*/;
144
145 virtual ::std::unique_ptr<::LevelStorageObserver> createLevelStorageObserver() /*override*/;
146
147 virtual void onSave(::std::string const& levelId) /*override*/;
148
149 virtual void onStorageChanged() /*override*/;
150
151 virtual ::Core::PathBuffer<::std::string> const getBasePath() const /*override*/;
152
153 virtual ::Core::PathBuffer<::std::string> const getPathToLevel(::std::string const& levelId) const /*override*/;
154 // NOLINTEND
155
156public:
157 // member functions
158 // NOLINTBEGIN
159 MCAPI LevelListCache(
160 ::LevelStorageSource& levelStorageSource,
161 ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const> appPlatform,
162 ::std::function<bool()>&& checkIsSafeToFlushCache
163 );
164
165 MCAPI ::LevelCache* _addOrReplaceCache(::Core::Path const& path);
166
167 MCAPI ::LevelCache* _addToCache(
168 ::std::string const& levelId,
169 ::LevelCache&& levelCache,
170 ::LevelListCacheObserver::LevelAddedType levelAddedType
171 );
172
173 MCAPI ::LevelCache* _createAndAddToCache(
174 ::std::string const& levelId,
175 ::Core::Path const& directory,
176 ::LevelListCacheObserver::LevelAddedType levelAddedType
177 );
178
179 MCAPI ::LevelCache* _getLevelCache(::std::string const& levelId);
180
181 MCAPI ::LevelSummary* _getLevelSummary(::std::string const& levelId);
182
183 MCAPI void _notifyLevelUpdated(::std::string const& levelId);
184
185 MCAPI void _notifyNewLevelFound(::std::string const& levelId, ::LevelListCacheObserver::LevelAddedType type);
186
187 MCAPI void _refreshSummary(::std::string const& levelId, ::LevelCache& cache);
188 // NOLINTEND
189
190public:
191 // constructor thunks
192 // NOLINTBEGIN
193 MCAPI void* $ctor(
194 ::LevelStorageSource& levelStorageSource,
195 ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const> appPlatform,
196 ::std::function<bool()>&& checkIsSafeToFlushCache
197 );
198 // NOLINTEND
199
200public:
201 // virtual function thunks
202 // NOLINTBEGIN
203 MCAPI void $addLevel(::std::string const& levelId, ::LevelData&& levelData);
204
205 MCAPI void $deleteLevel(::std::string const& levelId);
206
207 MCAPI void $refreshLevel(::std::string const& levelId);
208
209 MCAPI void $ensureLevelInitialized(::std::string const& levelId);
210
211 MCAPI void $deleteLevelFiles(::std::string const& levelId);
212
213 MCAPI void $postDeleteLevel(::std::string const& levelId);
214
215 MCAPI void $renameLevel(::std::string const& levelId, ::std::string const& newLevelName);
216
217 MCAPI void $renameAndSaveLevelData(
218 ::std::string const& levelId,
219 ::std::string const& newLevelName,
220 ::LevelData const& levelData
221 );
222
223 MCAPI void $saveLevelData(::std::string const& levelId, ::LevelData const& levelData);
224
225 MCAPI void $createBackupCopyOfWorld(
226 ::std::string const& levelId,
227 ::std::string const& newLevelId,
228 ::std::string const& newName
229 );
230
231 MCAPI bool $hasLevelWithId(::std::string const& levelId);
232
233 MCAPI ::std::string $getLevelIdFromPath(::Core::Path const& fullPath, ::Core::Path const& worldsPath);
234
235 MCAPI bool $checkIfLevelIsCorruptOrMissing(::std::string const& levelId);
236
237 MCAPI void $addObserver(::LevelListCacheObserver& observer);
238
239 MCAPI void $removeObserver(::LevelListCacheObserver& observer);
240
241 MCAPI ::Bedrock::UniqueOwnerPointer<::LevelStorage> $createLevelStorage(
242 ::Scheduler& scheduler,
243 ::std::string const& levelId,
244 ::ContentIdentity const& contentIdentity,
245 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider,
246 ::std::chrono::nanoseconds const& writeFlushInterval,
247 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
248 ::std::unique_ptr<::LevelStorageEventing> levelStorageEventing
249 );
250
251 MCAPI ::std::unique_ptr<::LevelLooseFileStorage> $createLevelLooseStorage(
252 ::std::string const& levelId,
253 ::ContentIdentity const& contentIdentity,
254 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider
255 );
256
257 MCAPI ::LevelSummary* $getLevelSummary(::std::string const& levelId);
258
259 MCAPI ::LevelSummary const* $getLevelSummaryByName(::std::string const& levelName);
260
261 MCAPI ::LevelSummary* $getOrCreateLevelSummary(::Core::Path const& directory);
262
263 MCAPI ::LevelData* $getLevelData(::std::string const& levelId);
264
265 MCAPI ::Bedrock::NonOwnerPointer<::LevelData> $getLevelDataNonOwnerPointer(::std::string const& levelId);
266
267 MCAPI ::LevelSummary* $getShallowLevelSummary(::std::string const& levelId);
268
269 MCAPI void $getLevelList(
270 ::std::vector<::LevelSummary>& dest,
271 bool includeShallowSummaries,
272 bool includePartiallyCopiedLevels,
273 bool includeBetaRetailLevels,
274 bool includeInvalidLevelDataLevels
275 );
276
277 MCAPI bool $hasCachedLevels(bool includeShallowSummaries) const;
278
279 MCAPI void $updateLevelCache(::std::string const& levelId);
280
281 MCAPI ::std::unique_ptr<::LevelStorageObserver> $createLevelStorageObserver();
282
283 MCAPI void $onSave(::std::string const& levelId);
284
285 MCAPI void $onStorageChanged();
286
287 MCAPI ::Core::PathBuffer<::std::string> const $getBasePath() const;
288
289 MCAPI ::Core::PathBuffer<::std::string> const $getPathToLevel(::std::string const& levelId) const;
290
291
292 // NOLINTEND
293};
Definition AppPlatform.h:78
Definition EnableQueueForMainThread.h:10
Definition LockGuard.h:8
Definition ContentIdentity.h:8
Definition Path.h:11
Definition IContentKeyProvider.h:13
Definition ILevelListCache.h:27
Definition LevelCache.h:14
Definition LevelData.h:55
Definition LevelDbEnv.h:8
Definition LevelListCacheObserver.h:13
Definition LevelLooseFileStorage.h:15
Definition LevelStorageEventing.h:16
Definition LevelStorageObserver.h:5
Definition LevelStorageSource.h:27
Definition LevelStorage.h:25
Definition Scheduler.h:14
Definition LevelSummary.h:30