LeviLamina
Loading...
Searching...
No Matches
ContentManager.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/gui/screens/models/ContentFlags.h"
7#include "mc/client/gui/screens/models/ContentManagerContextCollection.h"
8#include "mc/client/gui/screens/models/ContentType.h"
9#include "mc/client/gui/screens/models/IContentManager.h"
10#include "mc/deps/core/file/PathBuffer.h"
11#include "mc/deps/core/resource/PackType.h"
12#include "mc/deps/core/threading/Async.h"
13#include "mc/deps/core/utility/NonOwnerPointer.h"
14#include "mc/deps/core/utility/pub_sub/Publisher.h"
15#include "mc/world/level/LevelListCacheObserver.h"
16
17// auto generated forward declare list
18// clang-format off
22class ContentIdentity;
29class IEntitlementManager;
30class ILevelListCache;
36class Pack;
38class PackSource;
40class StoreCatalogRepository;
41class TaskGroup;
43struct ContentItem;
44struct ContentSource;
47namespace Bedrock::PubSub { class Subscription; }
48namespace Bedrock::PubSub::ThreadModel { struct SingleThreaded; }
49namespace ContentManagerUtils { class SourcesAsyncReloader; }
50namespace Core { class FilePathManager; }
51namespace Realms { class RealmsServicePackSource; }
52namespace Realms { struct Content; }
53namespace Realms { struct RealmId; }
54namespace StorageManager { class ContentItemProvider; }
55namespace StorageManager { class IContentHandler; }
56namespace StorageManager { class WorldConverter; }
57namespace mce { class UUID; }
58// clang-format on
59
62 public ::std::enable_shared_from_this<::ContentManager> {
63public:
64 // member variables
65 // NOLINTBEGIN
66 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ContentManager>> mSelf;
67 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IWorldTemplateManager>> mWorldTemplateManager;
68 ::ll::TypedStorage<8, 8, ::IPackManifestFactory&> mPackManifestFactory;
69 ::ll::TypedStorage<8, 16, ::gsl::not_null<::std::shared_ptr<::MutableContentItemCollection>>> mContent;
70 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::ContentSource>>> mContentSources;
71 ::ll::TypedStorage<8, 24, ::ContentManagerContextCollection> mContexts;
72 ::ll::TypedStorage<8, 8, uint64> mContentId;
73 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IContentCatalogPackSource>> mCatalogResourcePackSource;
74 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::Realms::RealmsServicePackSource>>>
75 mRealmsServicePackSources;
76 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::CachedHostPackIdProvider>> mCachedHostPackIdProvider;
77 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ContentManagerProxy>> mProxy;
78 ::ll::TypedStorage<1, 1, bool> mInitialized;
79 ::ll::TypedStorage<8, 32, ::std::string const> WORLD_RESOURCE_PACK_FILENAME;
80 ::ll::TypedStorage<8, 32, ::std::string const> WORLD_BEHAVIOR_PACK_FILENAME;
81 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager>> mFilePathManager;
82 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mMutex;
83 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IContentManagerFactory>> mFactory;
84 ::ll::TypedStorage<8, 16, ::gsl::not_null<::std::shared_ptr<::ContentManagerUtils::SourcesAsyncReloader>>>
85 mReloadSourcesAsync;
86 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager>> mEntitlementManager;
87 ::ll::TypedStorage<8, 48, ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::SingleThreaded, 0>>
88 mReloadViewsPublisher;
89 ::ll::TypedStorage<8, 48, ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::SingleThreaded, 0>>
90 mDeleteContentPublisher;
91 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::StorageManager::ContentItemProvider>> mWeakStorageContentItemProvider;
92 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::StorageManager::IContentHandler>>>
93 mStorageContentHandler;
94 ::ll::TypedStorage<8, 64, ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()>>
95 mStorageWorldConverterConstructor;
96 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::StorageManager::WorldConverter>> mWeakStorageWorldConverter;
97 // NOLINTEND
98
99public:
100 // prevent constructor by default
101 ContentManager& operator=(ContentManager const&);
102 ContentManager(ContentManager const&);
103 ContentManager();
104
105public:
106 // virtual functions
107 // NOLINTBEGIN
108 virtual ~ContentManager() /*override*/ = default;
109
110 virtual ::ContentSource* loadContent(::ContentType contentType, ::ContentFlags flags) /*override*/;
111
112 virtual ::ContentSource* loadContent(::InvalidPacksFilterGroup const& invalidFilter) /*override*/;
113
114 virtual ::ContentSource*
115 loadContentForLevel(::std::string const& levelId, ::mce::UUID const& premiumTemplateId) /*override*/;
116
117 virtual ::ContentSource* loadContentForRealm(int64 const realmId) /*override*/;
118
119 virtual ::std::unique_ptr<::ContentSource> loadContentForRealmsWorld(
120 ::Realms::RealmId realmId,
121 ::std::vector<::Realms::Content> const& servicePackData
122 ) /*override*/;
123
124 virtual void addPackSourceFromPremiumTemplate(
125 ::RealmPackManagerContentSource* source,
126 ::mce::UUID const& premiumTemplateId,
127 ::PackType packType
128 ) /*override*/;
129
130 virtual void addRealmsUnknownPackSources(::RealmPackManagerContentSource* contentSource) /*override*/;
131
132 virtual void addPacksToRealmsUnknownPackSource(::std::unique_ptr<::Pack> pack) /*override*/;
133
134 virtual void addCachedHostPackIdProvider(::std::weak_ptr<::CachedHostPackIdProvider> provider) /*override*/;
135
136 virtual void clearRealmsUnknownPackSource() /*override*/;
137
138 virtual void removeUnneededItemFromRealmsUnknownContentSource(::mce::UUID const& id) /*override*/;
139
140 virtual ::gsl::not_null<::std::shared_ptr<::ContentItemCollection>>
141 getGlobalResourcePackCollection(bool isEditorMode) /*override*/;
142
143 virtual ::std::unique_ptr<::IContentManagerContext>
144 createContext(::std::function<bool(::std::shared_ptr<::ContentItem const> const&)> contextPredicate) /*override*/;
145
146 virtual void removeContext(::IContentManagerContext& context) /*override*/;
147
148 virtual ::std::vector<::std::unique_ptr<::ContentSource>> const& getSources() const /*override*/;
149
150 virtual ::std::vector<::std::shared_ptr<::ContentItem>> getContentItems() const /*override*/;
151
152 virtual ::std::shared_ptr<::IVersionedContentItemCollection const> getVersionedItems() const /*override*/;
153
154 virtual void enableCatalogPackSource() /*override*/;
155
156 virtual void generateItems(::ContentSource* source) /*override*/;
157
158 virtual ::Bedrock::Threading::Async<void> reloadSources(bool saveSources) /*override*/;
159
160 virtual void reloadItems() /*override*/;
161
162 virtual void reloadViews() /*override*/;
163
164 virtual void populateDependencies() const /*override*/;
165
166 virtual void deleteContent(::std::shared_ptr<::ContentItem const> const& contentItem) /*override*/;
167
168 virtual void deleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) /*override*/;
169
170 virtual void deleteContentFiles(::std::shared_ptr<::ContentItem const> const& contentItem) /*override*/;
171
172 virtual void
173 deleteContentFiles(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) /*override*/;
174
175 virtual void postDeleteContent(::std::shared_ptr<::ContentItem const> const& contentItem) /*override*/;
176
177 virtual void
178 postDeleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) /*override*/;
179
180 virtual uint64 generateContentId() /*override*/;
181
182 virtual ::Core::PathBuffer<::std::string> const getWorldResourcePath(::std::string const& levelId) const
183 /*override*/;
184
185 virtual ::Core::PathBuffer<::std::string> const getWorldBehaviorPath(::std::string const& levelId) const
186 /*override*/;
187
188 virtual ::Core::PathBuffer<::std::string> const getWorldResourceFolder(::std::string const& levelId) const
189 /*override*/;
190
191 virtual ::Core::PathBuffer<::std::string> const getWorldBehaviorFolder(::std::string const& levelId) const
192 /*override*/;
193
194 virtual ::Core::PathBuffer<::std::string> const getWorldPath(::std::string const& levelId) const /*override*/;
195
196 virtual ::Core::PathBuffer<::std::string> const&
197 getPremiumWorldTemplateFolder(::ContentIdentity const& templateId) /*override*/;
198
199 virtual ::ContentManagerProxy* getProxy() /*override*/;
200
201 virtual void beginAsyncInit(::TaskGroup& taskGroup) /*override*/;
202
203 virtual bool isInitialized() const /*override*/;
204
205 virtual void onLanguageChanged() /*override*/;
206
207 virtual void refreshContentCatalogPackSource() /*override*/;
208
209 virtual ::Bedrock::PubSub::Subscription
210 refreshContentCatalogPackSource(::std::function<void()>&& callback) /*override*/;
211
212 virtual ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> getFilePathManager() /*override*/;
213
214 virtual void onLevelDeleted(::std::string const& levelId) /*override*/;
215
216 virtual void onRealmsReset(::Realms::RealmId const realmsId) /*override*/;
217
218 virtual ::Bedrock::PubSub::Subscription
219 subscribeToSourcesReloadedAsyncCompleted(::std::function<void()>&& onSourcesReloadedAsyncCallback) /*override*/;
220
221 virtual ::std::shared_ptr<::StorageManager::ContentItemProvider> getStorageContentItemProvider() /*override*/;
222
223 virtual ::StorageManager::IContentHandler& getStorageContentHandler() /*override*/;
224
225 virtual ::std::shared_ptr<::StorageManager::WorldConverter> getStorageWorldConverter() /*override*/;
226
227 virtual ::Bedrock::PubSub::Subscription registerToReloadViews(::std::function<void()> callback) /*override*/;
228
229 virtual ::Bedrock::PubSub::Subscription registerToDeleteContent(::std::function<void()> callback) /*override*/;
230 // NOLINTEND
231
232public:
233 // member functions
234 // NOLINTBEGIN
235 MCAPI ContentManager(
236 ::ILevelListCache& levelListCache,
237 ::Bedrock::NotNullNonOwnerPtr<::WorldTemplateManager> const& worldTemplateManager,
238 ::IResourcePackRepository& resourcePackRepository,
239 ::ResourcePackManager& resourcePackManager,
240 ::PackManifestFactory& packManifestFactory,
241 ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager> entitlementManager,
242 ::Bedrock::NotNullNonOwnerPtr<::IContentTierManager const> const& contentTierManager,
243 ::Bedrock::NotNullNonOwnerPtr<::StoreCatalogRepository> const& storeCatalog,
244 ::Bedrock::NotNullNonOwnerPtr<::ContentCatalogService> const& contentCatalogService,
245 ::ClientPackSourceFactory& packSourceFactory,
246 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& filePathManager,
247 ::std::unique_ptr<::StorageManager::IContentHandler> storageContentHandler,
248 ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()> storageWorldConverterConstructor
249 );
250
251 MCAPI void _removeContentItemsFromSource(::gsl::not_null<::ContentSource*> source);
252
253 MCAPI void _retrievePackSources(::PackType packType, ::std::vector<::PackSource*>& packSources);
254
255 MCAPI ::Bedrock::NotNullNonOwnerPtr<::Realms::RealmsServicePackSource> _updateOrCreateRealmsServicePackSource(
256 int64 realmId,
257 ::PackType packType,
258 ::std::vector<::gsl::not_null<::std::shared_ptr<::Pack>>>&& servicePackData
259 );
260 // NOLINTEND
261
262public:
263 // static functions
264 // NOLINTBEGIN
265 MCAPI static void _deleteContent(
266 ::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems,
267 ::std::function<void(::ContentSource&, ::std::vector<::std::shared_ptr<::ContentItem const>> const&)>
268 deleteItemCallback
269 );
270 // NOLINTEND
271
272public:
273 // constructor thunks
274 // NOLINTBEGIN
275 MCAPI void* $ctor(
276 ::ILevelListCache& levelListCache,
277 ::Bedrock::NotNullNonOwnerPtr<::WorldTemplateManager> const& worldTemplateManager,
278 ::IResourcePackRepository& resourcePackRepository,
279 ::ResourcePackManager& resourcePackManager,
280 ::PackManifestFactory& packManifestFactory,
281 ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager> entitlementManager,
282 ::Bedrock::NotNullNonOwnerPtr<::IContentTierManager const> const& contentTierManager,
283 ::Bedrock::NotNullNonOwnerPtr<::StoreCatalogRepository> const& storeCatalog,
284 ::Bedrock::NotNullNonOwnerPtr<::ContentCatalogService> const& contentCatalogService,
285 ::ClientPackSourceFactory& packSourceFactory,
286 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& filePathManager,
287 ::std::unique_ptr<::StorageManager::IContentHandler> storageContentHandler,
288 ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()> storageWorldConverterConstructor
289 );
290 // NOLINTEND
291
292public:
293 // virtual function thunks
294 // NOLINTBEGIN
295 MCAPI ::ContentSource* $loadContent(::ContentType contentType, ::ContentFlags flags);
296
297 MCAPI ::ContentSource* $loadContent(::InvalidPacksFilterGroup const& invalidFilter);
298
299 MCAPI ::ContentSource* $loadContentForLevel(::std::string const& levelId, ::mce::UUID const& premiumTemplateId);
300
301 MCAPI ::ContentSource* $loadContentForRealm(int64 const realmId);
302
303 MCAPI ::std::unique_ptr<::ContentSource>
304 $loadContentForRealmsWorld(::Realms::RealmId realmId, ::std::vector<::Realms::Content> const& servicePackData);
305
306 MCAPI void $addPackSourceFromPremiumTemplate(
307 ::RealmPackManagerContentSource* source,
308 ::mce::UUID const& premiumTemplateId,
309 ::PackType packType
310 );
311
312 MCAPI void $addRealmsUnknownPackSources(::RealmPackManagerContentSource* contentSource);
313
314 MCAPI void $addPacksToRealmsUnknownPackSource(::std::unique_ptr<::Pack> pack);
315
316 MCAPI void $addCachedHostPackIdProvider(::std::weak_ptr<::CachedHostPackIdProvider> provider);
317
318 MCAPI void $clearRealmsUnknownPackSource();
319
320 MCAPI void $removeUnneededItemFromRealmsUnknownContentSource(::mce::UUID const& id);
321
322 MCAPI ::gsl::not_null<::std::shared_ptr<::ContentItemCollection>>
323 $getGlobalResourcePackCollection(bool isEditorMode);
324
325 MCAPI ::std::unique_ptr<::IContentManagerContext>
326 $createContext(::std::function<bool(::std::shared_ptr<::ContentItem const> const&)> contextPredicate);
327
328 MCAPI void $removeContext(::IContentManagerContext& context);
329
330 MCFOLD ::std::vector<::std::unique_ptr<::ContentSource>> const& $getSources() const;
331
332 MCAPI ::std::vector<::std::shared_ptr<::ContentItem>> $getContentItems() const;
333
334 MCFOLD ::std::shared_ptr<::IVersionedContentItemCollection const> $getVersionedItems() const;
335
336 MCAPI void $enableCatalogPackSource();
337
338 MCAPI void $generateItems(::ContentSource* source);
339
340 MCAPI ::Bedrock::Threading::Async<void> $reloadSources(bool saveSources);
341
342 MCAPI void $reloadItems();
343
344 MCAPI void $reloadViews();
345
346 MCAPI void $populateDependencies() const;
347
348 MCAPI void $deleteContent(::std::shared_ptr<::ContentItem const> const& contentItem);
349
350 MCAPI void $deleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
351
352 MCAPI void $deleteContentFiles(::std::shared_ptr<::ContentItem const> const& contentItem);
353
354 MCAPI void $deleteContentFiles(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
355
356 MCAPI void $postDeleteContent(::std::shared_ptr<::ContentItem const> const& contentItem);
357
358 MCAPI void $postDeleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
359
360 MCAPI uint64 $generateContentId();
361
362 MCAPI ::Core::PathBuffer<::std::string> const $getWorldResourcePath(::std::string const& levelId) const;
363
364 MCAPI ::Core::PathBuffer<::std::string> const $getWorldBehaviorPath(::std::string const& levelId) const;
365
366 MCAPI ::Core::PathBuffer<::std::string> const $getWorldResourceFolder(::std::string const& levelId) const;
367
368 MCAPI ::Core::PathBuffer<::std::string> const $getWorldBehaviorFolder(::std::string const& levelId) const;
369
370 MCAPI ::Core::PathBuffer<::std::string> const $getWorldPath(::std::string const& levelId) const;
371
372 MCAPI ::Core::PathBuffer<::std::string> const& $getPremiumWorldTemplateFolder(::ContentIdentity const& templateId);
373
374 MCAPI ::ContentManagerProxy* $getProxy();
375
376 MCAPI void $beginAsyncInit(::TaskGroup& taskGroup);
377
378 MCAPI bool $isInitialized() const;
379
380 MCAPI void $onLanguageChanged();
381
382 MCAPI void $refreshContentCatalogPackSource();
383
384 MCAPI ::Bedrock::PubSub::Subscription $refreshContentCatalogPackSource(::std::function<void()>&& callback);
385
386 MCAPI ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> $getFilePathManager();
387
388 MCAPI void $onLevelDeleted(::std::string const& levelId);
389
390 MCAPI void $onRealmsReset(::Realms::RealmId const realmsId);
391
392 MCAPI ::Bedrock::PubSub::Subscription
393 $subscribeToSourcesReloadedAsyncCompleted(::std::function<void()>&& onSourcesReloadedAsyncCallback);
394
395 MCAPI ::std::shared_ptr<::StorageManager::ContentItemProvider> $getStorageContentItemProvider();
396
397 MCAPI ::StorageManager::IContentHandler& $getStorageContentHandler();
398
399 MCAPI ::std::shared_ptr<::StorageManager::WorldConverter> $getStorageWorldConverter();
400
401 MCAPI ::Bedrock::PubSub::Subscription $registerToReloadViews(::std::function<void()> callback);
402
403 MCAPI ::Bedrock::PubSub::Subscription $registerToDeleteContent(::std::function<void()> callback);
404 // NOLINTEND
405};
Definition Subscription.h:10
Definition CachedHostPackIdProvider.h:5
Definition ClientPackSourceFactory.h:5
Definition ContentCatalogService.h:5
Definition ContentIdentity.h:8
Definition ContentItemCollection.h:5
Definition ContentManagerProxy.h:5
Definition SourcesAsyncReloader.h:7
Definition ContentManager.h:5
Definition FilePathManager.h:18
Definition IContentCatalogPackSource.h:5
Definition IContentManagerContext.h:5
Definition IContentManagerFactory.h:5
Definition IContentManager.h:5
Definition IContentTierManager.h:13
Definition ILevelListCache.h:27
Definition IPackManifestFactory.h:17
Definition IResourcePackRepository.h:35
Definition IVersionedContentItemCollection.h:5
Definition IWorldTemplateManager.h:17
Definition LevelListCacheObserver.h:13
Definition MutableContentItemCollection.h:5
Definition PackManifestFactory.h:21
Definition PackSource.h:28
Definition Pack.h:28
Definition RealmsServicePackSource.h:18
Definition ResourcePackManager.h:36
Definition ContentItemProvider.h:7
Definition IContentHandler.h:7
Definition WorldConverter.h:7
Definition TaskGroup.h:86
Definition WorldTemplateManager.h:21
Definition UUID.h:8
Definition ContentItem.h:5
Definition ContentSource.h:5
Definition InvalidPacksFilterGroup.h:5
Definition RealmPackManagerContentSource.h:5
Definition Content.h:7
Definition RealmId.h:7