OpenShot Audio Library | OpenShotAudio: juce::DynamicObject Class Reference

OpenShot Audio Library | OpenShotAudio 1.0.0

Loading...
Searching...
No Matches
juce::DynamicObject Class Reference

`#include <juce_DynamicObject.h>`

Inheritance diagram for juce::DynamicObject:

## Public Types
using | Ptr = ReferenceCountedObjectPtr<DynamicObject>

## Public Member Functions
| DynamicObject (const DynamicObject &)
virtual bool | hasProperty (const Identifier &propertyName) const
virtual const var & | getProperty (const Identifier &propertyName) const
virtual void | setProperty (const Identifier &propertyName, const var &newValue)
virtual void | removeProperty (const Identifier &propertyName)
virtual bool | hasMethod (const Identifier &methodName) const
virtual var | invokeMethod (Identifier methodName, const var::NativeFunctionArgs &args)
void | setMethod (Identifier methodName, var::NativeFunction function)
void | clear ()
NamedValueSet & | getProperties () noexcept
const NamedValueSet & | getProperties () const noexcept
void | cloneAllProperties ()
virtual std::unique_ptr< DynamicObject > | clone () const
virtual void | writeAsJSON (OutputStream &, const JSON::FormatOptions &)
Public Member Functions inherited from juce::ReferenceCountedObject
void | incReferenceCount () noexcept
void | decReferenceCount () noexcept
bool | decReferenceCountWithoutDeleting () noexcept
int | getReferenceCount () const noexcept

## Additional Inherited Members
Protected Member Functions inherited from juce::ReferenceCountedObject
| ReferenceCountedObject ()=default
| ReferenceCountedObject (const ReferenceCountedObject &) noexcept
| ReferenceCountedObject (ReferenceCountedObject &&) noexcept
ReferenceCountedObject & | operator= (const ReferenceCountedObject &) noexcept
ReferenceCountedObject & | operator= (ReferenceCountedObject &&) noexcept
virtual | ~ReferenceCountedObject ()
void | resetReferenceCount () noexcept

## Detailed Description

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 39 of file juce_DynamicObject.h.

## Member Typedef Documentation

## ◆ Ptr

using juce::DynamicObject::Ptr = ReferenceCountedObjectPtr<DynamicObject>

Definition at line 47 of file juce_DynamicObject.h.

## Constructor & Destructor Documentation

## ◆ DynamicObject() [1/2]

juce::DynamicObject::DynamicObject | ( |  | ) |

Definition at line 26 of file juce_DynamicObject.cpp.

## ◆ DynamicObject() [2/2]

juce::DynamicObject::DynamicObject | ( | const DynamicObject & | other | ) |

Definition at line 30 of file juce_DynamicObject.cpp.

## ◆ ~DynamicObject()

juce::DynamicObject::~DynamicObject | ( |  | ) |
| override

Definition at line 35 of file juce_DynamicObject.cpp.

## Member Function Documentation

## ◆ clear()

void juce::DynamicObject::clear | ( |  | ) |

Removes all properties and methods from the object.

Definition at line 78 of file juce_DynamicObject.cpp.

Referenced by clear().

## ◆ clone()

std::unique_ptr< DynamicObject > juce::DynamicObject::clone | ( |  | ) | const
| 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.

Definition at line 90 of file juce_DynamicObject.cpp.

Referenced by clone().

## ◆ cloneAllProperties()

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 cloneAllProperties().

## ◆ getProperties() [1/2]

const NamedValueSet & juce::DynamicObject::getProperties | ( |  | ) | const
| inlinenoexcept

Returns the NamedValueSet that holds the object's properties.

Definition at line 102 of file juce_DynamicObject.h.

## ◆ getProperties() [2/2]

NamedValueSet & juce::DynamicObject::getProperties | ( |  | ) |
| inlinenoexcept

Returns the NamedValueSet that holds the object's properties.

Definition at line 99 of file juce_DynamicObject.h.

Referenced by juce::JSONUtils::deepEqual().

## ◆ getProperty()

const var & juce::DynamicObject::getProperty | ( | const Identifier & | propertyName | ) | const
| virtual

Returns a named property. This returns var() if no such property exists.

Definition at line 45 of file juce_DynamicObject.cpp.

Referenced by getProperty(), and hasMethod().

## ◆ hasMethod()

bool juce::DynamicObject::hasMethod | ( | const Identifier & | methodName | ) | const
| 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.

Referenced by hasMethod().

## ◆ hasProperty()

bool juce::DynamicObject::hasProperty | ( | const Identifier & | propertyName | ) | const
| 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.

Referenced by hasProperty().

## ◆ invokeMethod()

var juce::DynamicObject::invokeMethod | ( | Identifier | methodName,
|  | const var::NativeFunctionArgs & | args )
| 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 properties.

Definition at line 65 of file juce_DynamicObject.cpp.

Referenced by invokeMethod().

## ◆ removeProperty()

void juce::DynamicObject::removeProperty | ( | const Identifier & | propertyName | ) |
| virtual

Removes a named property.

Definition at line 55 of file juce_DynamicObject.cpp.

Referenced by removeProperty().

## ◆ setMethod()

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.

Referenced by setMethod().

## ◆ setProperty()

void juce::DynamicObject::setProperty | ( | const Identifier & | propertyName,
|  | const var & | newValue )
| virtual

Sets a named property.

Definition at line 50 of file juce_DynamicObject.cpp.

Referenced by setProperty().

## ◆ writeAsJSON()

void juce::DynamicObject::writeAsJSON | ( | OutputStream & | out,
|  | const JSON::FormatOptions & | format )
| 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.

Definition at line 97 of file juce_DynamicObject.cpp.

Referenced by writeAsJSON().

The documentation for this class was generated from the following files:

- juce_DynamicObject.h
- juce_DynamicObject.cpp