ArchiveEditorModule.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <Archive/ArchiveTypeIds.h>
  9. #include <ArchiveModuleInterface.h>
  10. #include "ArchiveEditorSystemComponent.h"
  11. #include "ArchiveWriterFactory.h"
  12. namespace Archive
  13. {
  14. class ArchiveEditorModule
  15. : public ArchiveModuleInterface
  16. {
  17. public:
  18. AZ_RTTI(ArchiveEditorModule, ArchiveEditorModuleTypeId, ArchiveModuleInterface);
  19. AZ_CLASS_ALLOCATOR(ArchiveEditorModule, AZ::SystemAllocator);
  20. ArchiveEditorModule()
  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. ArchiveEditorSystemComponent::CreateDescriptor(),
  28. });
  29. m_archiveWriterFactory = AZStd::make_unique<ArchiveWriterFactory>();
  30. ArchiveWriterFactoryInterface::Register(m_archiveWriterFactory.get());
  31. }
  32. ~ArchiveEditorModule()
  33. {
  34. ArchiveWriterFactoryInterface::Unregister(m_archiveWriterFactory.get());
  35. }
  36. /**
  37. * Add required SystemComponents to the SystemEntity.
  38. * Non-SystemComponents should not be added here
  39. */
  40. AZ::ComponentTypeList GetRequiredSystemComponents() const override
  41. {
  42. return AZ::ComponentTypeList {
  43. azrtti_typeid<ArchiveEditorSystemComponent>(),
  44. };
  45. }
  46. private:
  47. // ArchiveWriterFactory instance for the Tools module that allows
  48. // external gem modules to create ArchiveWriter instances
  49. AZStd::unique_ptr<IArchiveWriterFactory> m_archiveWriterFactory;
  50. };
  51. }// namespace Archive
  52. #if defined(O3DE_GEM_NAME)
  53. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME, _Editor), Archive::ArchiveEditorModule)
  54. #else
  55. AZ_DECLARE_MODULE_CLASS(Gem_Archive_Editor, Archive::ArchiveEditorModule)
  56. #endif