OpenShot Audio Library | OpenShotAudio: juce_Value.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0 |

Loading...
Searching...
No Matches
juce_Value.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
50 class JUCE_API Value final
51{
52public:
53 //==============================================================================
55 Value();
56
63 Value (const Value& other);
64
66 explicit Value (const var& initialValue);
67
69 Value (Value&&) noexcept;
70
72 ~Value();
73
74 //==============================================================================
76 var getValue() const;
77
79 operator var() const;
80
84 String toString() const;
85
93 void setValue (const var& newValue);
94
102 Value& operator= (const var& newValue);
103
105 Value& operator= (Value&&) noexcept;
106
115 void referTo (const Value& valueToReferTo);
116
120 bool refersToSameSourceAs (const Value& other) const;
121
126 bool operator== (const Value& other) const;
127
132 bool operator!= (const Value& other) const;
133
134 //==============================================================================
138 class JUCE_API Listener
139 {
140 public:
141 Listener() = default;
142 virtual ~Listener() = default;
143
150 virtual void valueChanged (Value& value) = 0;
151 };
152
164 void addListener (Listener* listener);
165
167 void removeListener (Listener* listener);
168
169
170 //==============================================================================
178 class JUCE_API ValueSource : public ReferenceCountedObject,
179 private AsyncUpdater
180 {
181 public:
182 ValueSource();
183 ~ValueSource() override;
184
186 virtual var getValue() const = 0;
187
191 virtual void setValue (const var& newValue) = 0;
192
199 void sendChangeMessage (bool dispatchSynchronously);
200
201 protected:
202 //==============================================================================
203 friend class Value;
204 SortedSet<Value*> valuesWithListeners;
205
206 private:
207 void handleAsyncUpdate() override;
208
209 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSource)
210 };
211
212
213 //==============================================================================
215 explicit Value (ValueSource* valueSource);
216
218 ValueSource& getValueSource() noexcept { return *value; }
219
220
221private:
222 //==============================================================================
223 friend class ValueSource;
224 ReferenceCountedObjectPtr<ValueSource> value;
225 ListenerList<Listener> listeners;
226
227 void callListeners();
228 void removeFromListenerList();
229
230 // This is disallowed to avoid confusion about whether it should
231 // do a by-value or by-reference copy.
232 Value& operator= (const Value&) = delete;
233
234 // This declaration prevents accidental construction from an integer of 0,
235 // which is possible in some compilers via an implicit cast to a pointer.
236 explicit Value (void*) = delete;
237};
238
240OutputStream& JUCE_CALLTYPE operator<< (OutputStream&, const Value&);
241
242
243} // namespace juce
juce::AsyncUpdater::AsyncUpdater
AsyncUpdater()
Definition juce_AsyncUpdater.cpp:44
juce::ListenerList
Definition juce_ListenerList.h:81
juce::ReferenceCountedObjectPtr
Definition juce_ReferenceCountedObject.h:247
juce::ReferenceCountedObject::ReferenceCountedObject
ReferenceCountedObject()=default
juce::SortedSet
Definition juce_SortedSet.h:54
juce::String
Definition juce_String.h:53
juce::Value::Listener
Definition juce_Value.h:139
juce::Value::Listener::valueChanged
virtual void valueChanged(Value &value)=0
juce::Value::ValueSource
Definition juce_Value.h:180
juce::Value::ValueSource::getValue
virtual var getValue() const =0
juce::Value::ValueSource::sendChangeMessage
void sendChangeMessage(bool dispatchSynchronously)
Definition juce_Value.cpp:43
juce::Value::ValueSource::setValue
virtual void setValue(const var &newValue)=0
juce::Value
Definition juce_Value.h:51
juce::Value::setValue
void setValue(const var &newValue)
Definition juce_Value.cpp:161
juce::Value::addListener
void addListener(Listener *listener)
Definition juce_Value.cpp:208
juce::Value::removeListener
void removeListener(Listener *listener)
Definition juce_Value.cpp:219
juce::Value::refersToSameSourceAs
bool refersToSameSourceAs(const Value &other) const
Definition juce_Value.cpp:192
juce::Value::getValueSource
ValueSource & getValueSource() noexcept
Definition juce_Value.h:218
juce::Value::referTo
void referTo(const Value &valueToReferTo)
Definition juce_Value.cpp:177
juce::Value::Value
Value()
Definition juce_Value.cpp:101
juce::Value::getValue
var getValue() const
Definition juce_Value.cpp:151
juce::Value::toString
String toString() const
Definition juce_Value.cpp:166
juce::var
Definition juce_Variant.h:42