ROS2FrameSystemBus.h 3.6 KB

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