Skip to content
LeviMC
English
AutoLightDark
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 ::ll::TypedStorage<8, 64, ::std::function<bool()>> mCheckIsCloudSyncAvailable;
54 // NOLINTEND
55
56public:
57 // prevent constructor by default
58 LevelListCache& operator=(LevelListCache const&);
59 LevelListCache(LevelListCache const&);
60 LevelListCache();
61
62public:
63 // virtual functions
64 // NOLINTBEGIN
65 virtual ~LevelListCache() /*override*/ = default;
66
67 virtual void addLevel(::std::string const& levelId, ::LevelData&& levelData) /*override*/;
68
69 virtual void deleteLevel(::std::string const& levelId) /*override*/;
70
71 virtual void refreshLevel(::std::string const& levelId) /*override*/;
72
73 virtual void ensureLevelInitialized(::std::string const& levelId) /*override*/;
74
75 virtual void deleteLevelFiles(::std::string const& levelId) /*override*/;
76
77 virtual void postDeleteLevel(::std::string const& levelId) /*override*/;
78
79 virtual void renameLevel(::std::string const& levelId, ::std::string const& newLevelName) /*override*/;
80
81 virtual void renameAndSaveLevelData(
82 ::std::string const& levelId,
83 ::std::string const& newLevelName,
84 ::LevelData const& levelData
85 ) /*override*/;
86
87 virtual void saveLevelData(::std::string const& levelId, ::LevelData const& levelData) /*override*/;
88
89 virtual void createBackupCopyOfWorld(
90 ::std::string const& levelId,
91 ::std::string const& newLevelId,
92 ::std::string const& newName
93 ) /*override*/;
94
95 virtual bool hasLevelWithId(::std::string const& levelId) /*override*/;
96
97 virtual ::std::string getLevelIdFromPath(::Core::Path const& fullPath, ::Core::Path const& worldsPath) /*override*/;
98
99 virtual bool checkIfLevelIsCorruptOrMissing(::std::string const& levelId) /*override*/;
100
101 virtual void addObserver(::LevelListCacheObserver& observer) /*override*/;
102
103 virtual void removeObserver(::LevelListCacheObserver& observer) /*override*/;
104
105 virtual ::Bedrock::UniqueOwnerPointer<::LevelStorage> createLevelStorage(
106 ::Scheduler& scheduler,
107 ::std::string const& levelId,
108 ::ContentIdentity const& contentIdentity,
109 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider,
110 ::std::chrono::nanoseconds const& writeFlushInterval,
111 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
112 ::std::unique_ptr<::LevelStorageEventing> levelStorageEventing
113 ) /*override*/;
114
115 virtual ::std::unique_ptr<::LevelLooseFileStorage> createLevelLooseStorage(
116 ::std::string const& levelId,
117 ::ContentIdentity const& contentIdentity,
118 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider
119 ) /*override*/;
120
121 virtual ::LevelSummary* getLevelSummary(::std::string const& levelId) /*override*/;
122
123 virtual ::LevelSummary const* getLevelSummaryByName(::std::string const& levelName) /*override*/;
124
125 virtual ::LevelSummary* getOrCreateLevelSummary(::Core::Path const& directory) /*override*/;
126
127 virtual ::LevelData* getLevelData(::std::string const& levelId) /*override*/;
128
129 virtual ::Bedrock::NonOwnerPointer<::LevelData>
130 getLevelDataNonOwnerPointer(::std::string const& levelId) /*override*/;
131
132 virtual ::LevelSummary* getShallowLevelSummary(::std::string const& levelId) /*override*/;
133
134 virtual void getLevelList(
135 ::std::vector<::LevelSummary>& dest,
136 bool includeShallowSummaries,
137 bool includePartiallyCopiedLevels,
138 bool includeBetaRetailLevels,
139 bool includeInvalidLevelDataLevels
140 ) /*override*/;
141
142 virtual bool hasCachedLevels(bool includeShallowSummaries) const /*override*/;
143
144 virtual void updateLevelCache(::std::string const& levelId) /*override*/;
145
146 virtual ::std::unique_ptr<::LevelStorageObserver> createLevelStorageObserver() /*override*/;
147
148 virtual void onSave(::std::string const& levelId) /*override*/;
149
150 virtual void onStorageChanged() /*override*/;
151
152 virtual ::Core::PathBuffer<::std::string> const getBasePath() const /*override*/;
153
154 virtual ::Core::PathBuffer<::std::string> const getPathToLevel(::std::string const& levelId) const /*override*/;
155 // NOLINTEND
156
157public:
158 // member functions
159 // NOLINTBEGIN
161 ::LevelStorageSource& levelStorageSource,
162 ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const> appPlatform,
163 ::std::function<bool()>&& checkIsSafeToFlushCache,
164 ::std::function<bool()>&& checkIsCloudSyncAvailable
165 );
166
167 MCNAPI ::LevelCache* _addOrReplaceCache(::Core::Path const& path);
168
169 MCNAPI ::LevelCache* _addToCache(
170 ::std::string const& levelId,
171 ::LevelCache&& levelCache,
172 ::LevelListCacheObserver::LevelAddedType levelAddedType
173 );
174
175 MCNAPI ::LevelCache* _createAndAddToCache(
176 ::std::string const& levelId,
177 ::Core::Path const& directory,
178 ::LevelListCacheObserver::LevelAddedType levelAddedType
179 );
180
181 MCNAPI ::LevelCache* _getLevelCache(::std::string const& levelId);
182
183 MCNAPI ::LevelSummary* _getLevelSummary(::std::string const& levelId);
184
185 MCNAPI void _notifyLevelUpdated(::std::string const& levelId);
186
187 MCNAPI void _notifyNewLevelFound(::std::string const& levelId, ::LevelListCacheObserver::LevelAddedType type);
188
189 MCNAPI void _refreshSummary(::std::string const& levelId, ::LevelCache& cache);
190 // NOLINTEND
191
192public:
193 // constructor thunks
194 // NOLINTBEGIN
195 MCNAPI void* $ctor(
196 ::LevelStorageSource& levelStorageSource,
197 ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const> appPlatform,
198 ::std::function<bool()>&& checkIsSafeToFlushCache,
199 ::std::function<bool()>&& checkIsCloudSyncAvailable
200 );
201 // NOLINTEND
202
203public:
204 // virtual function thunks
205 // NOLINTBEGIN
206 MCNAPI void $addLevel(::std::string const& levelId, ::LevelData&& levelData);
207
208 MCNAPI void $deleteLevel(::std::string const& levelId);
209
210 MCNAPI void $refreshLevel(::std::string const& levelId);
211
212 MCNAPI void $ensureLevelInitialized(::std::string const& levelId);
213
214 MCNAPI void $deleteLevelFiles(::std::string const& levelId);
215
216 MCNAPI void $postDeleteLevel(::std::string const& levelId);
217
218 MCNAPI void $renameLevel(::std::string const& levelId, ::std::string const& newLevelName);
219
221 ::std::string const& levelId,
222 ::std::string const& newLevelName,
223 ::LevelData const& levelData
224 );
225
226 MCNAPI void $saveLevelData(::std::string const& levelId, ::LevelData const& levelData);
227
229 ::std::string const& levelId,
230 ::std::string const& newLevelId,
231 ::std::string const& newName
232 );
233
234 MCNAPI bool $hasLevelWithId(::std::string const& levelId);
235
236 MCNAPI ::std::string $getLevelIdFromPath(::Core::Path const& fullPath, ::Core::Path const& worldsPath);
237
238 MCNAPI bool $checkIfLevelIsCorruptOrMissing(::std::string const& levelId);
239
241
243
244 MCNAPI ::Bedrock::UniqueOwnerPointer<::LevelStorage> $createLevelStorage(
245 ::Scheduler& scheduler,
246 ::std::string const& levelId,
247 ::ContentIdentity const& contentIdentity,
248 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider,
249 ::std::chrono::nanoseconds const& writeFlushInterval,
250 ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv> levelDbEnv,
251 ::std::unique_ptr<::LevelStorageEventing> levelStorageEventing
252 );
253
254 MCNAPI ::std::unique_ptr<::LevelLooseFileStorage> $createLevelLooseStorage(
255 ::std::string const& levelId,
256 ::ContentIdentity const& contentIdentity,
257 ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const> const& keyProvider
258 );
259
260 MCNAPI ::LevelSummary* $getLevelSummary(::std::string const& levelId);
261
262 MCNAPI ::LevelSummary const* $getLevelSummaryByName(::std::string const& levelName);
263
264 MCNAPI ::LevelSummary* $getOrCreateLevelSummary(::Core::Path const& directory);
265
266 MCNAPI ::LevelData* $getLevelData(::std::string const& levelId);
267
268 MCNAPI ::Bedrock::NonOwnerPointer<::LevelData> $getLevelDataNonOwnerPointer(::std::string const& levelId);
269
270 MCNAPI ::LevelSummary* $getShallowLevelSummary(::std::string const& levelId);
271
272 MCNAPI void $getLevelList(
273 ::std::vector<::LevelSummary>& dest,
274 bool includeShallowSummaries,
275 bool includePartiallyCopiedLevels,
276 bool includeBetaRetailLevels,
277 bool includeInvalidLevelDataLevels
278 );
279
280 MCNAPI bool $hasCachedLevels(bool includeShallowSummaries) const;
281
282 MCNAPI void $updateLevelCache(::std::string const& levelId);
283
284 MCNAPI ::std::unique_ptr<::LevelStorageObserver> $createLevelStorageObserver();
285
286 MCNAPI void $onSave(::std::string const& levelId);
287
288 MCNAPI void $onStorageChanged();
289
290 MCNAPI ::Core::PathBuffer<::std::string> const $getBasePath() const;
291
292 MCNAPI ::Core::PathBuffer<::std::string> const $getPathToLevel(::std::string const& levelId) const;
293
294
295 // NOLINTEND
296};
Definition AppPlatform.h:79
Definition EnableQueueForMainThread.h:10
Definition LockGuard.h:8
Definition ContentIdentity.h:8
Definition Path.h:10
Definition IContentKeyProvider.h:13
Definition ILevelListCache.h:27
Definition LevelCache.h:14
Definition LevelData.h:57
Definition LevelDbEnv.h:8
Definition LevelListCacheObserver.h:13
MCAPI void $deleteLevel(::std::string const &levelId)
MCAPI bool $hasLevelWithId(::std::string const &levelId)
MCAPI void $renameLevel(::std::string const &levelId, ::std::string const &newLevelName)
MCAPI::LevelCache * _getLevelCache(::std::string const &levelId)
MCAPI void $removeObserver(::LevelListCacheObserver &observer)
MCAPI::LevelCache * _addOrReplaceCache(::Core::Path const &path)
MCAPI::LevelSummary const * $getLevelSummaryByName(::std::string const &levelName)
MCAPI::LevelCache * _addToCache(::std::string const &levelId, ::LevelCache &&levelCache, ::LevelListCacheObserver::LevelAddedType levelAddedType)
MCAPI void $onSave(::std::string const &levelId)
MCAPI::LevelSummary * $getLevelSummary(::std::string const &levelId)
MCAPI::LevelSummary * _getLevelSummary(::std::string const &levelId)
MCAPI void $refreshLevel(::std::string const &levelId)
MCAPI void $ensureLevelInitialized(::std::string const &levelId)
MCAPI ::Bedrock::NonOwnerPointer<::LevelData > $getLevelDataNonOwnerPointer(::std::string const &levelId)
MCAPI ::Core::PathBuffer<::std::string > const $getBasePath() const
MCAPI::std::string $getLevelIdFromPath(::Core::Path const &fullPath, ::Core::Path const &worldsPath)
MCAPI bool $hasCachedLevels(bool includeShallowSummaries) const
MCAPI void _notifyNewLevelFound(::std::string const &levelId, ::LevelListCacheObserver::LevelAddedType type)
MCAPI void $addLevel(::std::string const &levelId, ::LevelData &&levelData)
MCAPI void * $ctor(::LevelStorageSource &levelStorageSource, ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const > appPlatform, ::std::function< bool()> &&checkIsSafeToFlushCache, ::std::function< bool()> &&checkIsCloudSyncAvailable)
MCAPI void $addObserver(::LevelListCacheObserver &observer)
MCAPI void $renameAndSaveLevelData(::std::string const &levelId, ::std::string const &newLevelName, ::LevelData const &levelData)
MCAPI void $deleteLevelFiles(::std::string const &levelId)
MCAPI void $saveLevelData(::std::string const &levelId, ::LevelData const &levelData)
MCAPI::LevelCache * _createAndAddToCache(::std::string const &levelId, ::Core::Path const &directory, ::LevelListCacheObserver::LevelAddedType levelAddedType)
MCAPI bool $checkIfLevelIsCorruptOrMissing(::std::string const &levelId)
MCAPI void $createBackupCopyOfWorld(::std::string const &levelId, ::std::string const &newLevelId, ::std::string const &newName)
MCAPI ::std::unique_ptr<::LevelLooseFileStorage > $createLevelLooseStorage(::std::string const &levelId, ::ContentIdentity const &contentIdentity, ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const > const &keyProvider)
MCAPI::LevelSummary * $getShallowLevelSummary(::std::string const &levelId)
MCAPI void $updateLevelCache(::std::string const &levelId)
MCAPI::LevelSummary * $getOrCreateLevelSummary(::Core::Path const &directory)
MCAPI LevelListCache(::LevelStorageSource &levelStorageSource, ::Bedrock::NotNullNonOwnerPtr<::AppPlatform const > appPlatform, ::std::function< bool()> &&checkIsSafeToFlushCache, ::std::function< bool()> &&checkIsCloudSyncAvailable)
MCAPI void _refreshSummary(::std::string const &levelId, ::LevelCache &cache)
MCAPI void _notifyLevelUpdated(::std::string const &levelId)
MCAPI void $getLevelList(::std::vector<::LevelSummary > &dest, bool includeShallowSummaries, bool includePartiallyCopiedLevels, bool includeBetaRetailLevels, bool includeInvalidLevelDataLevels)
MCAPI void $onStorageChanged()
MCAPI void $postDeleteLevel(::std::string const &levelId)
MCAPI ::Core::PathBuffer<::std::string > const $getPathToLevel(::std::string const &levelId) const
MCAPI::LevelData * $getLevelData(::std::string const &levelId)
MCAPI ::Bedrock::UniqueOwnerPointer<::LevelStorage > $createLevelStorage(::Scheduler &scheduler, ::std::string const &levelId, ::ContentIdentity const &contentIdentity, ::Bedrock::NotNullNonOwnerPtr<::IContentKeyProvider const > const &keyProvider, ::std::chrono::nanoseconds const &writeFlushInterval, ::Bedrock::NotNullNonOwnerPtr<::LevelDbEnv > levelDbEnv, ::std::unique_ptr<::LevelStorageEventing > levelStorageEventing)
MCAPI ::std::unique_ptr<::LevelStorageObserver > $createLevelStorageObserver()
Definition LevelLooseFileStorage.h:15
Definition LevelStorageEventing.h:19
Definition LevelStorageObserver.h:5
Definition LevelStorageSource.h:27
Definition LevelStorage.h:26
Definition Scheduler.h:15
Definition LevelSummary.h:30