SceneSerializationBus.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/EBus/EBus.h>
  10. #include <AzCore/Math/Uuid.h>
  11. #include <AzCore/std/parallel/mutex.h>
  12. #include <AzCore/std/smart_ptr/shared_ptr.h>
  13. #include <AzCore/std/string/string.h>
  14. namespace AZ
  15. {
  16. namespace SceneAPI
  17. {
  18. namespace Containers
  19. {
  20. class Scene;
  21. }
  22. namespace Events
  23. {
  24. //! EBus to deal with serialization to and from disks of scene and manifest files.
  25. class SceneSerialization
  26. : public AZ::EBusTraits
  27. {
  28. public:
  29. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  30. // Use a mutex to lock the EBus in case tools are running on different threads.
  31. using MutexType = AZStd::recursive_mutex;
  32. virtual ~SceneSerialization() = 0;
  33. //! Loads a scene and its corresponding manifest if available, otherwise a new manifest
  34. //! is created.
  35. //! @param sceneFilePath The absolute or relative path to the scene file in the source folder.
  36. //! @param sceneSourceGuid The source uuid for the scene file. If a null-uuid is given LoadScene will attempt to query the Asset Processor for the uuid.
  37. //! @param watchFolder is the scan folder that it was found inside
  38. //! @return The loaded scene or null if the file couldn't be fully resolved or an error
  39. //! occurred during loading.
  40. virtual AZStd::shared_ptr<Containers::Scene> LoadScene(const AZStd::string& sceneFilePath, Uuid sceneSourceGuid, const AZStd::string& watchFolder) = 0;
  41. //! The scene system caches loaded scenes. This checks if the given scene is valid and in the cache or not.
  42. //! @param sceneFilePath The absolute or relative path to the scene file in the source folder.
  43. //! @return True if the given scene is actively cached, false if not.
  44. virtual bool IsSceneCached(const AZStd::string& /*sceneFilePath*/) { return false; }
  45. };
  46. using SceneSerializationBus = AZ::EBus<SceneSerialization>;
  47. inline SceneSerialization::~SceneSerialization() = default;
  48. } // namespace Events
  49. } // namespace SceneAPI
  50. } // namespace AZ