LUABreakpointTrackerMessages.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef LUAEDITOR_LUABREAKPOINTTRACKERMESSAGES_H
  9. #define LUAEDITOR_LUABREAKPOINTTRACKERMESSAGES_H
  10. #include <AzCore/base.h>
  11. #include <AzCore/EBus/EBus.h>
  12. #include <AzCore/Asset/AssetCommon.h>
  13. #pragma once
  14. namespace AZ { class ReflectContext; }
  15. namespace LUAEditor
  16. {
  17. // combined, name+line is a unique breakpoint
  18. // this data definition is used by anyone tracking breakpoints
  19. // which currently includes the main context, editor and breakpoint control panel
  20. class Breakpoint
  21. {
  22. public:
  23. AZ_RTTI(Breakpoint, "{6E203CB5-C09B-433D-BA31-177762F574B8}");
  24. AZ_CLASS_ALLOCATOR(Breakpoint, AZ::SystemAllocator);
  25. virtual ~Breakpoint() = default;
  26. AZ::Uuid m_breakpointId; // a globally unique ID for every breakpoint.
  27. AZStd::string m_assetId; // the assetId of the document that the breakpoint was created for;
  28. int m_documentLine; // the line in the document that the breakpoint was set on.
  29. AZStd::string m_assetName;
  30. void RepurposeToNewOwner(const AZStd::string& newAssetName, const AZStd::string& newAssetId);
  31. static void Reflect(AZ::ReflectContext* reflection);
  32. };
  33. typedef AZStd::unordered_map<AZ::Uuid, Breakpoint> BreakpointMap;
  34. // messages going FROM the lua Context TO anyone interested in breakpoints
  35. class LUABreakpointTrackerMessages
  36. : public AZ::EBusTraits
  37. {
  38. public:
  39. //////////////////////////////////////////////////////////////////////////
  40. // Bus configuration
  41. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to
  42. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners
  43. //////////////////////////////////////////////////////////////////////////
  44. typedef AZ::EBus<LUABreakpointTrackerMessages> Bus;
  45. typedef Bus::Handler Handler;
  46. virtual void BreakpointsUpdate(const BreakpointMap& uniqueBreakpoints) = 0;
  47. virtual void BreakpointHit(const Breakpoint& bp) = 0;
  48. virtual void BreakpointResume() = 0;
  49. virtual ~LUABreakpointTrackerMessages() {}
  50. };
  51. // messages going TO the lua Context FROM anyone interested in retrieving breakpoint info
  52. class LUABreakpointRequestMessages
  53. : public AZ::EBusTraits
  54. {
  55. public:
  56. //////////////////////////////////////////////////////////////////////////
  57. // Bus configuration
  58. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to
  59. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Single; // we only have one listener
  60. //////////////////////////////////////////////////////////////////////////
  61. typedef AZ::EBus<LUABreakpointRequestMessages> Bus;
  62. typedef Bus::Handler Handler;
  63. virtual const BreakpointMap* RequestBreakpoints() = 0;
  64. virtual void RequestEditorFocus(const AZStd::string& assetIdString, int lineNumber) = 0;
  65. virtual void RequestDeleteBreakpoint(const AZStd::string& assetIdString, int lineNumber) = 0;
  66. virtual ~LUABreakpointRequestMessages() {}
  67. };
  68. }
  69. #endif//LUAEDITOR_LUABREAKPOINTTRACKERMESSAGES_H