OpenShot Library | libopenshot-audio 0.2.0
|
Represents a dynamically implemented object. More...
#include <juce_DynamicObject.h>
Public Types | |
using | Ptr = ReferenceCountedObjectPtr< DynamicObject > |
Public Member Functions | |
DynamicObject (const DynamicObject &) | |
virtual bool | hasProperty (const Identifier &propertyName) const |
Returns true if the object has a property with this name. | |
virtual const var & | getProperty (const Identifier &propertyName) const |
Returns a named property. | |
virtual void | setProperty (const Identifier &propertyName, const var &newValue) |
Sets a named property. | |
virtual void | removeProperty (const Identifier &propertyName) |
Removes a named property. | |
virtual bool | hasMethod (const Identifier &methodName) const |
Checks whether this object has the specified method. | |
virtual var | invokeMethod (Identifier methodName, const var::NativeFunctionArgs &args) |
Invokes a named method on this object. | |
void | setMethod (Identifier methodName, var::NativeFunction function) |
Adds a method to the class. | |
void | clear () |
Removes all properties and methods from the object. | |
NamedValueSet & | getProperties () noexcept |
Returns the NamedValueSet that holds the object's properties. | |
void | cloneAllProperties () |
Calls var::clone() on all the properties that this object contains. | |
virtual Ptr | clone () |
Returns a clone of this object. | |
virtual void | writeAsJSON (OutputStream &, int indentLevel, bool allOnOneLine, int maximumDecimalPlaces) |
Writes this object to a text stream in JSON format. | |
![]() | |
void | incReferenceCount () noexcept |
Increments the object's reference count. | |
void | decReferenceCount () noexcept |
Decreases the object's reference count. | |
bool | decReferenceCountWithoutDeleting () noexcept |
Decreases the object's reference count. | |
int | getReferenceCount () const noexcept |
Returns the object's current reference count. | |
Additional Inherited Members | |
![]() | |
ReferenceCountedObject ()=default | |
Creates the reference-counted object (with an initial ref count of zero). | |
ReferenceCountedObject (const ReferenceCountedObject &) noexcept | |
Copying from another object does not affect this one's reference-count. | |
ReferenceCountedObject (ReferenceCountedObject &&) noexcept | |
Copying from another object does not affect this one's reference-count. | |
ReferenceCountedObject & | operator= (const ReferenceCountedObject &) noexcept |
Copying from another object does not affect this one's reference-count. | |
ReferenceCountedObject & | operator= (ReferenceCountedObject &&) noexcept |
Copying from another object does not affect this one's reference-count. | |
virtual | ~ReferenceCountedObject () |
Destructor. | |
void | resetReferenceCount () noexcept |
Resets the reference count to zero without deleting the object. | |
Represents a dynamically implemented object.
This class is primarily intended for wrapping scripting language objects, but could be used for other purposes.
An instance of a DynamicObject can be used to store named properties, and by subclassing hasMethod() and invokeMethod(), you can give your object methods.
Definition at line 43 of file juce_DynamicObject.h.
Definition at line 51 of file juce_DynamicObject.h.
juce::DynamicObject::DynamicObject | ( | ) |
Definition at line 26 of file juce_DynamicObject.cpp.
juce::DynamicObject::DynamicObject | ( | const DynamicObject & | other | ) |
Definition at line 30 of file juce_DynamicObject.cpp.
|
override |
Definition at line 35 of file juce_DynamicObject.cpp.
|
virtual |
Returns true if the object has a property with this name.
Note that if the property is actually a method, this will return false.
Definition at line 39 of file juce_DynamicObject.cpp.
|
virtual |
Returns a named property.
This returns var() if no such property exists.
Definition at line 45 of file juce_DynamicObject.cpp.
|
virtual |
Sets a named property.
Definition at line 50 of file juce_DynamicObject.cpp.
|
virtual |
Removes a named property.
Definition at line 55 of file juce_DynamicObject.cpp.
References juce::var::remove().
|
virtual |
Checks whether this object has the specified method.
The default implementation of this just checks whether there's a property with this name that's actually a method, but this can be overridden for building objects with dynamic invocation.
Definition at line 60 of file juce_DynamicObject.cpp.
|
virtual |
Invokes a named method on this object.
The default implementation looks up the named property, and if it's a method call, then it invokes it.
This method is virtual to allow more dynamic invocation to used for objects where the methods may not already be set as properies.
Definition at line 65 of file juce_DynamicObject.cpp.
void juce::DynamicObject::setMethod | ( | Identifier | methodName, |
var::NativeFunction | function | ||
) |
Adds a method to the class.
This is basically the same as calling setProperty (methodName, (var::NativeFunction) myFunction), but helps to avoid accidentally invoking the wrong type of var constructor. It also makes the code easier to read,
Definition at line 73 of file juce_DynamicObject.cpp.
void juce::DynamicObject::clear | ( | ) |
Removes all properties and methods from the object.
Definition at line 78 of file juce_DynamicObject.cpp.
|
inlinenoexcept |
Returns the NamedValueSet that holds the object's properties.
Definition at line 103 of file juce_DynamicObject.h.
void juce::DynamicObject::cloneAllProperties | ( | ) |
Calls var::clone() on all the properties that this object contains.
Definition at line 83 of file juce_DynamicObject.cpp.
Referenced by clone().
|
virtual |
Returns a clone of this object.
The default implementation of this method just returns a new DynamicObject with a (deep) copy of all of its properties. Subclasses can override this to implement their own custom copy routines.
Reimplemented in juce::JavascriptEngine::RootObject::FunctionObject.
Definition at line 90 of file juce_DynamicObject.cpp.
References cloneAllProperties().
|
virtual |
Writes this object to a text stream in JSON format.
This method is used by JSON::toString and JSON::writeToStream, and you should never need to call it directly, but it's virtual so that custom object types can stringify themselves appropriately.
Reimplemented in juce::JavascriptEngine::RootObject::FunctionObject.
Definition at line 97 of file juce_DynamicObject.cpp.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size().