/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include #include #include #include #include #include #include #include #include namespace AzFramework { class AssetBundleManifest; } namespace LmbrCentral { struct OpenBundleInfo { OpenBundleInfo() = default; AZStd::shared_ptr m_manifest; AZStd::shared_ptr m_catalog; }; /** * System component for managing bundles */ class BundlingSystemComponent : public AZ::Component , public BundlingSystemRequestBus::Handler , public AZ::IO::ArchiveNotificationBus::Handler { public: AZ_COMPONENT(BundlingSystemComponent, "{0FB7153D-EE80-4B1C-9584-134270401AAF}"); static void Reflect(AZ::ReflectContext* context); BundlingSystemComponent() = default; protected: static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) { provided.push_back(AZ_CRC("BundlingService", 0xc9a43659)); } // AZ::Component void Activate() override; void Deactivate() override; // BundlingSystemRequestBus void LoadBundles(const char* baseFolder, const char* fileExtension) override; void UnloadBundles() override; void BundleOpened(const char* bundleName, AZStd::shared_ptr bundleManifest, const char* nextBundle, AZStd::shared_ptr bundleCatalog) override; void BundleClosed(const char* bundleName) override; AZStd::vector GetBundleList(const char* bundlePath, const char* bundleExtension) const; //! Bundles which are split across archives (Usually due to size constraints) have the dependent bundles listed in the manifest //! of the main bundle. This method manages opening the dependent bundles. void OpenDependentBundles(const char* bundleName, AZStd::shared_ptr bundleManifest); //! Bundles which are split across archives (Usually due to size constraints) have the dependent bundles listed in the manifest //! of the main bundle. This method manages closing the dependent bundles. void CloseDependentBundles(const char* bundleName, AZStd::shared_ptr bundleManifest); size_t GetOpenedBundleCount() const override; private: // Maintain a list of all opened bundles as reported through the BundleOpened ebus AZStd::unordered_map> m_openedBundles; // Used to maintain the order of the opened bundles to properly apply catalog info AZStd::vector m_openedBundleList; // Maintain a list of bundles opened through our "LoadBundles" command. // We'll unmount only this list rather than all opened bundles when calling UnloadBundles AZStd::vector m_bundleModeBundles; mutable AZStd::mutex m_openedBundleMutex; AZStd::mutex m_bundleModeMutex; }; }