CompressionEditorModule.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include "CompressionRegistrarImpl.h"
  9. #include "CompressionEditorSystemComponent.h"
  10. #include <CompressionModuleInterface.h>
  11. #include <Compression/CompressionTypeIds.h>
  12. namespace Compression
  13. {
  14. class CompressionEditorModule
  15. : public CompressionModuleInterface
  16. {
  17. public:
  18. AZ_RTTI(CompressionEditorModule, CompressionEditorModuleTypeId, CompressionModuleInterface);
  19. AZ_CLASS_ALLOCATOR(CompressionEditorModule, AZ::SystemAllocator);
  20. CompressionEditorModule()
  21. {
  22. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
  23. // Add ALL components descriptors associated with this gem to m_descriptors.
  24. // This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
  25. // This happens through the [MyComponent]::Reflect() function.
  26. m_descriptors.insert(m_descriptors.end(), {
  27. CompressionEditorSystemComponent::CreateDescriptor(),
  28. });
  29. m_compressionRegistrarInterface = AZStd::make_unique<CompressionRegistrarImpl>();
  30. if (CompressionRegistrar::Get() == nullptr)
  31. {
  32. CompressionRegistrar::Register(m_compressionRegistrarInterface.get());
  33. }
  34. }
  35. ~CompressionEditorModule()
  36. {
  37. if (CompressionRegistrar::Get() == m_compressionRegistrarInterface.get())
  38. {
  39. CompressionRegistrar::Unregister(m_compressionRegistrarInterface.get());
  40. }
  41. }
  42. /**
  43. * Add required SystemComponents to the SystemEntity.
  44. * Non-SystemComponents should not be added here
  45. */
  46. AZ::ComponentTypeList GetRequiredSystemComponents() const override
  47. {
  48. return AZ::ComponentTypeList {
  49. azrtti_typeid<CompressionEditorSystemComponent>(),
  50. };
  51. }
  52. private:
  53. // CompressionRegistrar interface used to register Compression interfaces
  54. // Available in tooling applications to allow compression algorithms to run
  55. AZStd::unique_ptr<CompressionRegistrarInterface> m_compressionRegistrarInterface;
  56. };
  57. }// namespace Compression
  58. #if defined(O3DE_GEM_NAME)
  59. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME), Compression::CompressionEditorModule)
  60. #else
  61. AZ_DECLARE_MODULE_CLASS(Gem_Compression, Compression::CompressionEditorModule)
  62. #endif