12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
- * its licensors.
- *
- * For complete copyright and license terms please see the LICENSE at the root of this
- * distribution (the "License"). All use of this software is governed by the License,
- * or, if provided, by the license below or the license accompanying this file. Do not
- * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- */
- #pragma once
- #include <AzFramework/Asset/AssetSystemBus.h>
- namespace AtomSampleViewer
- {
- //! Utility for tracking status of assets being built by the asset processor so scripts can insert delays
- class AssetStatusTracker final
- : public AzFramework::AssetSystemInfoBus::Handler
- {
- public:
- ~AssetStatusTracker();
- //! Starts tracking asset status updates from the Asset Processor.
- //! Clears any asset status information already collected.
- //! Clears any asset expectations that were added by ExpectAsset().
- void StartTracking();
- //! Sets the AssetStatusTracker to expect a particular asset with specific expected results.
- //! Note this can be called multiple times with the same assetPath, in which case the expected counts will be added.
- //! @param sourceAssetPath the source asset path, relative to the watch folder. Will be normalized and matched case-insensitive.
- //! @param expectedCount number of completed jobs expected for this asset.
- void ExpectAsset(AZStd::string sourceAssetPath, uint32_t expectedCount = 1);
- //! Returns whether all of the expected assets have finished.
- bool DidExpectedAssetsFinish() const;
- //! Stops tracking asset status updates from the Asset Processor. Clears any asset status information already collected.
- void StopTracking();
- private:
- // Tracks the number of times various events occur
- struct AssetStatusEvents
- {
- uint32_t m_started = 0;
- uint32_t m_succeeded = 0;
- uint32_t m_failed = 0;
- uint32_t m_expecteCount = 0;
- };
- // AssetSystemInfoBus overrides...
- void AssetCompilationStarted(const AZStd::string& assetPath) override;
- void AssetCompilationSuccess(const AZStd::string& assetPath) override;
- void AssetCompilationFailed(const AZStd::string& assetPath) override;
- bool m_isTracking = false;
- AZStd::unordered_map<AZStd::string /*asset path*/, AssetStatusEvents> m_allAssetStatusData;
- mutable AZStd::mutex m_mutex;
- };
- } // namespace AtomSampleViewer
|