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.

84 lines
2.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_ACTIONBROADCASTER_H_INCLUDED
  18. #define JUCE_ACTIONBROADCASTER_H_INCLUDED
  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. */
  25. class JUCE_API ActionBroadcaster
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates an ActionBroadcaster. */
  30. ActionBroadcaster();
  31. /** Destructor. */
  32. virtual ~ActionBroadcaster();
  33. //==============================================================================
  34. /** Adds a listener to the list.
  35. Trying to add a listener that's already on the list will have no effect.
  36. */
  37. void addActionListener (ActionListener* listener);
  38. /** Removes a listener from the list.
  39. If the listener isn't on the list, this won't have any effect.
  40. */
  41. void removeActionListener (ActionListener* listener);
  42. /** Removes all listeners from the list. */
  43. void removeAllActionListeners();
  44. //==============================================================================
  45. /** Broadcasts a message to all the registered listeners.
  46. @see ActionListener::actionListenerCallback
  47. */
  48. void sendActionMessage (const String& message) const;
  49. private:
  50. //==============================================================================
  51. friend class WeakReference<ActionBroadcaster>;
  52. WeakReference<ActionBroadcaster>::Master masterReference;
  53. class ActionMessage;
  54. friend class ActionMessage;
  55. SortedSet <ActionListener*> actionListeners;
  56. CriticalSection actionListenerLock;
  57. JUCE_DECLARE_NON_COPYABLE (ActionBroadcaster)
  58. };
  59. #endif // JUCE_ACTIONBROADCASTER_H_INCLUDED