ROS2FrameSystemBus.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/Component/EntityId.h>
  10. #include <AzCore/EBus/EBus.h>
  11. #include <AzCore/EBus/Policies.h>
  12. #include <AzCore/Interface/Interface.h>
  13. #include <AzCore/RTTI/RTTIMacros.h>
  14. #include <AzCore/std/string/string.h>
  15. #include <ROS2/Frame/ROS2FrameComponent.h>
  16. #include <AzCore/Component/EntityId.h>
  17. #include <AzCore/EBus/EBus.h>
  18. namespace ROS2
  19. {
  20. class ROS2FrameSystemRequests
  21. {
  22. public:
  23. AZ_RTTI(ROS2FrameSystemRequests, "{24fe4584-0499-4a37-bc1a-00ca04bd22f5}");
  24. //! Registers the ROS2FrameEditorComponent into the ROS2FrameSystemComponent. All ROS2FrameEditorComponents should
  25. //! register using this function during activation.
  26. //! This is used to properly handle the entity tree and namespaces, for the ROS2FrameEditorComponents.
  27. //! @param frameEntityId entityId containing the frame to register.
  28. virtual void RegisterFrame(const AZ::EntityId& frameEntityId) = 0;
  29. //! Unregister the ROS2FrameEditorComponent into the system. All ROS2FrameEditorComponents should
  30. //! unregister using this function during deactivation.
  31. //! @param frameEntityId entityId containing the frame to unregister.
  32. virtual void UnregisterFrame(const AZ::EntityId& frameEntityId) = 0;
  33. //! Move the frame in the entity tree.
  34. //! Moves the frame entity and updates all namespaces.
  35. //! Used by the ROS2FrameSystemComponent to change the frames configuration after entity move in the editor.
  36. //! @param frameEntityId entityId of the frame to move.
  37. //! @param newParent entityId of the new parent of the moved frame (does not need to be a entity
  38. //! containing a frame component).
  39. virtual void MoveFrame(const AZ::EntityId& frameEntityId, const AZ::EntityId& newParent) = 0;
  40. //! Notify the system entity about frames configuration change.
  41. //! This function should be called when a frame entity has changed its reflected configuration.
  42. //! @param frameEntityId entityId of the frame components entity that has changed its configuration.
  43. virtual void NotifyChange(const AZ::EntityId& frameEntityId) = 0;
  44. //! Check if the frame is the highest frame in the entity tree.
  45. //! @param frameEntityId entityId of the frame to check.
  46. //! @return boolean value of the check. True for top level.
  47. virtual bool IsTopLevel(const AZ::EntityId& frameEntityId) const = 0;
  48. //! Find the parent frame of the entity.
  49. //! @param frameEntityId entityId of the frame to check.
  50. //! @return entityId of the parent frame or an invalid entityId if the frame is top level.
  51. virtual AZ::EntityId GetParentEntityId(const AZ::EntityId& frameEntityId) const = 0;
  52. //! Find all frame children of the frame.
  53. //! @param frameEntityId entityId of the frame to check.
  54. //! @return set of all entityIds of children. Empty if no children or the frameEntityId is invalid.
  55. virtual AZStd::set<AZ::EntityId> GetChildrenEntityId(const AZ::EntityId& frameEntityId) const = 0;
  56. };
  57. class ROS2FrameSystemBusTraits : public AZ::EBusTraits
  58. {
  59. public:
  60. static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  61. static constexpr AZ::EBusHandlerPolicy AddressPolicy = AZ::EBusHandlerPolicy::Single;
  62. };
  63. using ROS2FrameSystemInterface = AZ::Interface<ROS2FrameSystemRequests>;
  64. using ROS2FrameSystemBus = AZ::EBus<ROS2FrameSystemRequests>;
  65. } // namespace ROS2