Switchboard Extension SDK
Loading...
Searching...
No Matches
switchboard::SwitchboardObject Class Reference

SwitchboardObject interface. More...

#include <SwitchboardObject.hpp>

Inheritance diagram for switchboard::SwitchboardObject:
switchboard::EventEmitter switchboard::Extension switchboard::Node switchboard::AudioNode switchboard::AudioProcessorNode switchboard::AudioSinkNode switchboard::AudioSourceNode switchboard::SingleBusAudioProcessorNode switchboard::SingleBusAudioSinkNode switchboard::SingleBusAudioSourceNode

Public Member Functions

 SwitchboardObject (const std::string &objectType)
 SwitchboardObject constructor.
 ~SwitchboardObject () override
 SwitchboardObject destructor.
std::string getObjectID () const
 Gets the ID of the object.
void setObjectID (const std::string &objectID)
 Sets the ID of the object.
std::string getURI ()
 Gets the URI of the object.
std::string getObjectType () const
 Gets the type of the object.
std::optional< std::string > getObjectSubtype () const
 Gets the subtype of the object.
void setObjectSubtype (std::optional< std::string > subtype)
 Sets the subtype of the object.
SwitchboardObjectgetParentObject () const
 Gets the parent object of the object.
void setParentObject (SwitchboardObject *parentObject)
 Sets the parent object of the object.
virtual Result< void > setValue (const std::string &key, const SBAny &value)
 Sets a value on the object.
virtual Result< SBAny > getValue (const std::string &key)
 Gets a value from the object.
virtual Result< SBAny > callAction (const std::string &actionName, const SBAnyMap &params)
 Calls an action on the object.
void registerConfiguration (const std::string &key, const SBAnyMap &schema, const SBAny &value)
 Registers a configuration for the object using a static schema and an instance value.
void setConfigurationValue (const std::string &key, const SBAny &value)
 Sets a configuration value for the object.
void registerProperty (const std::string &key, const SBAnyMap &schema, const SBAny &getter=SBAny(), const SBAny &setter=SBAny())
 Registers a property for the object.
void registerAction (const std::string &key, const SBAnyMap &schema, ActionHandler handler={})
 Registers an action for the object.
void registerEvent (const std::string &eventName, const SBAnyMap &eventInfo)
 Registers an event for the object.
Public Member Functions inherited from switchboard::EventEmitter
 EventEmitter ()
 Constructor for the EventEmitter class.
virtual ~EventEmitter ()
 Destructor for the EventEmitter class.
unsigned int addEventListener (const std::string &eventName, Callback callback)
 Adds a new event listener to the object.
bool removeEventListener (unsigned int listenerID)
 Removes an event listener from the object.

Additional Inherited Members

Public Types inherited from switchboard::EventEmitter
using Callback = std::function<void(const std::string&, const SBAny&)>
Protected Member Functions inherited from switchboard::EventEmitter
void emitEvent (const std::string &eventName, const SBAny &data)
 Emits an event.

Detailed Description

SwitchboardObject interface.

Constructor & Destructor Documentation

◆ SwitchboardObject()

switchboard::SwitchboardObject::SwitchboardObject ( const std::string & objectType)
explicit

SwitchboardObject constructor.

Parameters
objectTypeThe type of the object.

Member Function Documentation

◆ callAction()

virtual Result< SBAny > switchboard::SwitchboardObject::callAction ( const std::string & actionName,
const SBAnyMap & params )
virtual

Calls an action on the object.

Parameters
actionNameThe name of the action.
paramsThe parameters of the action.
Returns
The result of the action.

Reimplemented in switchboard::Node.

◆ getObjectID()

std::string switchboard::SwitchboardObject::getObjectID ( ) const

Gets the ID of the object.

Returns
The ID of the object.

◆ getObjectSubtype()

std::optional< std::string > switchboard::SwitchboardObject::getObjectSubtype ( ) const

Gets the subtype of the object.

Returns
The subtype of the object, or nullopt if not set.

◆ getObjectType()

std::string switchboard::SwitchboardObject::getObjectType ( ) const

Gets the type of the object.

Returns
The type of the object.

◆ getParentObject()

SwitchboardObject * switchboard::SwitchboardObject::getParentObject ( ) const

Gets the parent object of the object.

Returns
The parent object of the object.

◆ getURI()

std::string switchboard::SwitchboardObject::getURI ( )

Gets the URI of the object.

Returns
The URI of the object.

◆ getValue()

virtual Result< SBAny > switchboard::SwitchboardObject::getValue ( const std::string & key)
virtual

Gets a value from the object.

Parameters
keyThe key of the value.
Returns
The value.

Reimplemented in switchboard::Node.

◆ registerAction()

void switchboard::SwitchboardObject::registerAction ( const std::string & key,
const SBAnyMap & schema,
ActionHandler handler = {} )

Registers an action for the object.

Copies schema and attaches handler as the ACTION_FIELD_HANDLER entry if non-empty. Intended for use with NodeTypeInfo::getAction() so the schema lives once per type and only the handler is supplied per instance.

Parameters
keyThe key of the action.
schemaThe static schema for the action (typically from NodeTypeInfo).
handlerThe instance-bound callable that implements the action. May be empty for schema-only registrations dispatched via callAction() override.

◆ registerConfiguration()

void switchboard::SwitchboardObject::registerConfiguration ( const std::string & key,
const SBAnyMap & schema,
const SBAny & value )

Registers a configuration for the object using a static schema and an instance value.

Copies schema and attaches value as the CONFIGURATION_FIELD_VALUE entry. Intended for use with NodeTypeInfo::getConfiguration() so the schema lives once per type and only the live value is supplied per instance.

Parameters
keyThe key of the configuration.
schemaThe static schema for the configuration (typically from NodeTypeInfo).
valueThe current/initial value for this instance.

◆ registerEvent()

void switchboard::SwitchboardObject::registerEvent ( const std::string & eventName,
const SBAnyMap & eventInfo )

Registers an event for the object.

Parameters
eventNameThe name of the event.
eventInfoThe information about the event.

◆ registerProperty()

void switchboard::SwitchboardObject::registerProperty ( const std::string & key,
const SBAnyMap & schema,
const SBAny & getter = SBAny(),
const SBAny & setter = SBAny() )

Registers a property for the object.

Copies schema and attaches getter / setter as the PROPERTY_FIELD_GETTER / PROPERTY_FIELD_SETTER entries if non-empty. Intended for use with NodeTypeInfo::getProperty() so the schema lives once per type and only the callbacks are supplied per instance.

Parameters
keyThe key of the property.
schemaThe static schema for the property (typically from NodeTypeInfo).
getterThe instance-bound getter callable. May be empty for value-backed properties. Accepted forms: std::function<SBAny()> or std::function<Result<SBAny>()>.
setterThe instance-bound setter callable. May be empty for read-only properties. Accepted forms: std::function<void(const SBAny&)> or std::function<Result<void>(const SBAny&)>.

◆ setConfigurationValue()

void switchboard::SwitchboardObject::setConfigurationValue ( const std::string & key,
const SBAny & value )

Sets a configuration value for the object.

Parameters
keyThe key of the configuration.
valueThe value to set.

◆ setObjectID()

void switchboard::SwitchboardObject::setObjectID ( const std::string & objectID)

Sets the ID of the object.

Parameters
objectIDThe ID to set.

◆ setObjectSubtype()

void switchboard::SwitchboardObject::setObjectSubtype ( std::optional< std::string > subtype)

Sets the subtype of the object.

Parameters
subtypeThe subtype to set.

◆ setParentObject()

void switchboard::SwitchboardObject::setParentObject ( SwitchboardObject * parentObject)

Sets the parent object of the object.

Parameters
parentObjectThe parent object to set.

◆ setValue()

virtual Result< void > switchboard::SwitchboardObject::setValue ( const std::string & key,
const SBAny & value )
virtual

Sets a value on the object.

Parameters
keyThe key of the value.
valueThe value to set.
Returns
A successful result if the value was set successfully, an error result otherwise.

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