00001 /* 00002 ============================================================================== 00003 00004 This file is part of the JUCE library - "Jules' Utility Class Extensions" 00005 Copyright 2004-7 by Raw Material Software ltd. 00006 00007 ------------------------------------------------------------------------------ 00008 00009 JUCE can be redistributed and/or modified under the terms of the 00010 GNU General Public License, as published by the Free Software Foundation; 00011 either version 2 of the License, or (at your option) any later version. 00012 00013 JUCE is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with JUCE; if not, visit www.gnu.org/licenses or write to the 00020 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00021 Boston, MA 02111-1307 USA 00022 00023 ------------------------------------------------------------------------------ 00024 00025 If you'd like to release a closed-source product which uses JUCE, commercial 00026 licenses are also available: visit www.rawmaterialsoftware.com/juce for 00027 more information. 00028 00029 ============================================================================== 00030 */ 00031 00032 #ifndef __JUCE_CHANGELISTENERLIST_JUCEHEADER__ 00033 #define __JUCE_CHANGELISTENERLIST_JUCEHEADER__ 00034 00035 #include "juce_ChangeListener.h" 00036 #include "juce_MessageListener.h" 00037 #include "../../juce_core/containers/juce_SortedSet.h" 00038 #include "../../juce_core/threads/juce_ScopedLock.h" 00039 00040 00041 //============================================================================== 00050 class JUCE_API ChangeListenerList : public MessageListener 00051 { 00052 public: 00053 //============================================================================== 00055 ChangeListenerList() throw(); 00056 00058 ~ChangeListenerList() throw(); 00059 00060 //============================================================================== 00065 void addChangeListener (ChangeListener* const listener) throw(); 00066 00071 void removeChangeListener (ChangeListener* const listener) throw(); 00072 00074 void removeAllChangeListeners() throw(); 00075 00076 //============================================================================== 00094 void sendChangeMessage (void* objectThatHasChanged) throw(); 00095 00101 void sendSynchronousChangeMessage (void* objectThatHasChanged); 00102 00106 void dispatchPendingMessages(); 00107 00108 //============================================================================== 00110 void handleMessage (const Message&); 00111 00112 juce_UseDebuggingNewOperator 00113 00114 private: 00115 SortedSet <void*> listeners; 00116 CriticalSection lock; 00117 void* lastChangedObject; 00118 bool messagePending; 00119 00120 ChangeListenerList (const ChangeListenerList&); 00121 const ChangeListenerList& operator= (const ChangeListenerList&); 00122 }; 00123 00124 00125 #endif // __JUCE_CHANGELISTENERLIST_JUCEHEADER__