OpenShot Library | OpenShotAudio  0.2.1
juce_ActionBroadcaster.h
1 
2 /** @weakgroup juce_events-broadcasters
3  * @{
4  */
5 /*
6  ==============================================================================
7 
8  This file is part of the JUCE library.
9  Copyright (c) 2017 - ROLI Ltd.
10 
11  JUCE is an open source library subject to commercial or open-source
12  licensing.
13 
14  The code included in this file is provided under the terms of the ISC license
15  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16  To use, copy, modify, and/or distribute this software for any purpose with or
17  without fee is hereby granted provided that the above copyright notice and
18  this permission notice appear in all copies.
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 
30 //==============================================================================
31 /** Manages a list of ActionListeners, and can send them messages.
32 
33  To quickly add methods to your class that can add/remove action
34  listeners and broadcast to them, you can derive from this.
35 
36  @see ActionListener, ChangeListener
37 
38  @tags{Events}
39 */
41 {
42 public:
43  //==============================================================================
44  /** Creates an ActionBroadcaster. */
46 
47  /** Destructor. */
48  virtual ~ActionBroadcaster();
49 
50  //==============================================================================
51  /** Adds a listener to the list.
52  Trying to add a listener that's already on the list will have no effect.
53  */
54  void addActionListener (ActionListener* listener);
55 
56  /** Removes a listener from the list.
57  If the listener isn't on the list, this won't have any effect.
58  */
59  void removeActionListener (ActionListener* listener);
60 
61  /** Removes all listeners from the list. */
62  void removeAllActionListeners();
63 
64  //==============================================================================
65  /** Broadcasts a message to all the registered listeners.
66  @see ActionListener::actionListenerCallback
67  */
68  void sendActionMessage (const String& message) const;
69 
70 
71 private:
72  //==============================================================================
73  class ActionMessage;
74  friend class ActionMessage;
75 
76  SortedSet<ActionListener*> actionListeners;
77  CriticalSection actionListenerLock;
78 
79  JUCE_DECLARE_WEAK_REFERENCEABLE (ActionBroadcaster)
80  JUCE_DECLARE_NON_COPYABLE (ActionBroadcaster)
81 };
82 
83 } // namespace juce
84 
85 /** @}*/
#define JUCE_API
This macro is added to all JUCE public class declarations.
Interface class for delivery of events that are sent by an ActionBroadcaster.
The JUCE String class!
Definition: juce_String.h:42
Holds a set of unique primitive objects, such as ints or doubles.
A re-entrant mutex.
Manages a list of ActionListeners, and can send them messages.