29Value::ValueSource::ValueSource()
33Value::ValueSource::~ValueSource()
35 cancelPendingUpdate();
38void Value::ValueSource::handleAsyncUpdate()
40 sendChangeMessage (
true);
53 cancelPendingUpdate();
56 if (
Value*
const v = valuesWithListeners[i])
75 : value (initialValue)
89 sendChangeMessage (
false);
124 other.removeFromListenerList();
125 value = std::move (
other.value);
134 other.removeFromListenerList();
135 value = std::move (
other.value);
141 removeFromListenerList();
144void Value::removeFromListenerList()
146 if (listeners.size() > 0 && value !=
nullptr)
147 value->valuesWithListeners.removeValue (
this);
153 return value->getValue();
156Value::operator
var()
const
158 return value->getValue();
163 value->setValue (newValue);
168 return value->getValue().toString();
173 value->setValue (newValue);
181 if (listeners.size() > 0)
183 value->valuesWithListeners.removeValue (
this);
194 return value ==
other.value;
199 return value ==
other.value || value->getValue() ==
other.getValue();
204 return value !=
other.value && value->getValue() !=
other.getValue();
210 if (listener !=
nullptr)
212 if (listeners.size() == 0)
213 value->valuesWithListeners.add (
this);
215 listeners.add (listener);
221 listeners.remove (listener);
223 if (listeners.size() == 0)
224 value->valuesWithListeners.removeValue (
this);
227void Value::callListeners()
229 if (listeners.size() > 0)
The base class for streams that write data to some kind of destination.
A smart-pointer class which points to a reference-counted object.
var getValue() const override
Returns the current value of this object.
void setValue(const var &newValue) override
Changes the current value.
Receives callbacks when a Value object changes.
Used internally by the Value class as the base class for its shared value objects.
void sendChangeMessage(bool dispatchSynchronously)
Delivers a change message to all the listeners that are registered with this value.
Represents a shared variant value.
bool operator==(const Value &other) const
Compares two values.
void setValue(const var &newValue)
Sets the current value.
void addListener(Listener *listener)
Adds a listener to receive callbacks when the value changes.
void removeListener(Listener *listener)
Removes a listener that was previously added with addListener().
bool refersToSameSourceAs(const Value &other) const
Returns true if this object and the other one use the same underlying ValueSource object.
Value & operator=(const var &newValue)
Sets the current value.
void referTo(const Value &valueToReferTo)
Makes this object refer to the same underlying ValueSource as another one.
Value()
Creates an empty Value, containing a void var.
var getValue() const
Returns the current value.
bool operator!=(const Value &other) const
Compares two values.
String toString() const
Returns the value as a string.
A variant class, that can be used to hold a range of primitive values.
bool equalsWithSameType(const var &other) const noexcept
Returns true if this var has the same value and type as the one supplied.
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...