JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Value.h
Go to the documentation of this file.
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//==============================================================================
50class 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
210 };
211
212
213 //==============================================================================
215 explicit Value (ValueSource* valueSource);
216
218 ValueSource& getValueSource() noexcept { return *value; }
219
220
221private:
222 //==============================================================================
223 friend class ValueSource;
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
Has a callback method that is triggered asynchronously.
Holds a set of objects and can invoke a member function callback on each object in the set with a sin...
A smart-pointer class which points to a reference-counted object.
A base class which provides methods for reference-counting.
Holds a set of unique primitive objects, such as ints or doubles.
The JUCE String class!
Definition juce_String.h:53
Receives callbacks when a Value object changes.
Definition juce_Value.h:139
virtual void valueChanged(Value &value)=0
Called when a Value object is changed.
Used internally by the Value class as the base class for its shared value objects.
Definition juce_Value.h:180
virtual var getValue() const =0
Returns the current value of this object.
virtual void setValue(const var &newValue)=0
Changes the current value.
Represents a shared variant value.
Definition juce_Value.h:51
ValueSource & getValueSource() noexcept
Returns the ValueSource that this value is referring to.
Definition juce_Value.h:218
A variant class, that can be used to hold a range of primitive values.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
JUCE Namespace.
OutputStream &JUCE_CALLTYPE operator<<(OutputStream &stream, const BigInteger &value)
Writes a BigInteger to an OutputStream as a UTF8 decimal string.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88