PythonReflectionComponent.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 <EditorPythonBindings/EditorPythonBindingsSymbols.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <EditorPythonBindings/EditorPythonBindingsBus.h>
  12. #include <EditorPythonBindings/PythonCommon.h>
  13. #include <pybind11/pybind11.h>
  14. namespace EditorPythonBindings
  15. {
  16. namespace Internal
  17. {
  18. struct StaticPropertyHolderMap;
  19. }
  20. //! Inspects the Behavior Context for methods to expose as Python bindings
  21. class PythonReflectionComponent
  22. : public AZ::Component
  23. , private EditorPythonBindings::EditorPythonBindingsNotificationBus::Handler
  24. {
  25. public:
  26. AZ_COMPONENT(PythonReflectionComponent, PythonReflectionComponentTypeId, AZ::Component);
  27. static void Reflect(AZ::ReflectContext* context);
  28. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  29. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  30. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  31. protected:
  32. ////////////////////////////////////////////////////////////////////////
  33. // AZ::Component interface implementation
  34. void Activate() override;
  35. void Deactivate() override;
  36. ////////////////////////////////////////////////////////////////////////
  37. ////////////////////////////////////////////////////////////////////////
  38. // EditorPythonBindings::EditorPythonBindingsNotificationBus interface implementation
  39. void OnPreFinalize() override;
  40. void OnImportModule(PyObject* module) override;
  41. ////////////////////////////////////////////////////////////////////////
  42. private:
  43. void ExportGlobalsFromBehaviorContext(pybind11::module parentModule);
  44. AZStd::shared_ptr<Internal::StaticPropertyHolderMap> m_staticPropertyHolderMap;
  45. };
  46. }