Loading...
Searching...
No Matches
juce_ChangeBroadcaster.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API ChangeBroadcaster
{
public:
//==============================================================================
ChangeBroadcaster() noexcept;
virtual ~ChangeBroadcaster();
//==============================================================================
void addChangeListener (ChangeListener* listener);
void removeChangeListener (ChangeListener* listener);
void removeAllChangeListeners();
//==============================================================================
void sendChangeMessage();
void sendSynchronousChangeMessage();
void dispatchPendingMessages();
private:
//==============================================================================
class ChangeBroadcasterCallback : public AsyncUpdater
{
public:
ChangeBroadcasterCallback();
~ChangeBroadcasterCallback() override { cancelPendingUpdate(); }
void handleAsyncUpdate() override;
ChangeBroadcaster* owner;
};
friend class ChangeBroadcasterCallback;
ChangeBroadcasterCallback broadcastCallback;
ListenerList <ChangeListener> changeListeners;
std::atomic<bool> anyListeners { false };
void callListeners();
JUCE_DECLARE_NON_COPYABLE (ChangeBroadcaster)
};
} // namespace juce
juce::AsyncUpdater
Definition juce_AsyncUpdater.h:39
juce::ChangeBroadcaster::sendChangeMessage
void sendChangeMessage()
Definition juce_ChangeBroadcaster.cpp:65
juce::ChangeBroadcaster::ChangeBroadcaster
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
juce::ChangeBroadcaster::addChangeListener
void addChangeListener(ChangeListener *listener)
Definition juce_ChangeBroadcaster.cpp:35
juce::ChangeBroadcaster::removeChangeListener
void removeChangeListener(ChangeListener *listener)
Definition juce_ChangeBroadcaster.cpp:45
juce::ChangeBroadcaster::removeAllChangeListeners
void removeAllChangeListeners()
Definition juce_ChangeBroadcaster.cpp:55
juce::ChangeBroadcaster::sendSynchronousChangeMessage
void sendSynchronousChangeMessage()
Definition juce_ChangeBroadcaster.cpp:71
juce::ChangeBroadcaster::dispatchPendingMessages
void dispatchPendingMessages()
Definition juce_ChangeBroadcaster.cpp:80
juce::ChangeListener
Definition juce_ChangeListener.h:45