Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /** Manages a list of ActionListeners, and can send them messages.
  21. To quickly add methods to your class that can add/remove action
  22. listeners and broadcast to them, you can derive from this.
  23. @see ActionListener, ChangeListener
  24. @tags{Events}
  25. */
  26. class JUCE_API ActionBroadcaster
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates an ActionBroadcaster. */
  31. ActionBroadcaster();
  32. /** Destructor. */
  33. virtual ~ActionBroadcaster();
  34. //==============================================================================
  35. /** Adds a listener to the list.
  36. Trying to add a listener that's already on the list will have no effect.
  37. */
  38. void addActionListener (ActionListener* listener);
  39. /** Removes a listener from the list.
  40. If the listener isn't on the list, this won't have any effect.
  41. */
  42. void removeActionListener (ActionListener* listener);
  43. /** Removes all listeners from the list. */
  44. void removeAllActionListeners();
  45. //==============================================================================
  46. /** Broadcasts a message to all the registered listeners.
  47. @see ActionListener::actionListenerCallback
  48. */
  49. void sendActionMessage (const String& message) const;
  50. private:
  51. //==============================================================================
  52. class ActionMessage;
  53. friend class ActionMessage;
  54. SortedSet<ActionListener*> actionListeners;
  55. CriticalSection actionListenerLock;
  56. JUCE_DECLARE_WEAK_REFERENCEABLE (ActionBroadcaster)
  57. JUCE_DECLARE_NON_COPYABLE (ActionBroadcaster)
  58. };
  59. } // namespace juce