Switchboard Extension SDK
Loading...
Searching...
No Matches
SwitchboardObject.hpp
1//
2// SwitchboardObject.hpp
3// SwitchboardSDK
4//
5// Created by Balazs Kiss on 2025. 01. 22..
6//
7
8#pragma once
9
10#include <switchboard/export.h>
11#include <switchboard_core/EventEmitter.hpp>
12#include <switchboard/SBAny.hpp>
13#include <switchboard_core/SwitchboardCore.hpp>
14#include <switchboard_core/Configuration.hpp>
15#include <switchboard_core/Property.hpp>
16#include <switchboard_core/Action.hpp>
17#include <switchboard_core/Event.hpp>
18
19#include <any>
20#include <map>
21#include <memory>
22#include <string>
23#include <switchboard/Result.hpp>
24
25namespace switchboard {
26
27namespace SwitchboardObjectType {
28 inline constexpr const char* SWITCHBOARD = "switchboard";
29 inline constexpr const char* ENGINE = "engine";
30 inline constexpr const char* GRAPH = "graph";
31 inline constexpr const char* NODE = "node";
32 inline constexpr const char* EXTENSION = "extension";
33}
34
38class SWITCHBOARDSDK_EXPORT SwitchboardObject : public EventEmitter {
39public:
40
46 explicit SwitchboardObject(const std::string& objectType);
47
52
58 std::string getObjectID() const;
59
65 void setObjectID(const std::string& objectID);
66
72 std::string getURI();
73
79 std::string getObjectType() const;
80
86 std::optional<std::string> getObjectSubtype() const;
87
93 void setObjectSubtype(std::optional<std::string> subtype);
94
101
108
117 virtual Result<void> setValue(const std::string& key, const SBAny& value);
118
126 virtual Result<SBAny> getValue(const std::string& key);
127
136 virtual Result<SBAny> callAction(const std::string& actionName, const SBAnyMap& params);
137
144 void registerConfiguration(const std::string& key, const SBAnyMap& configuration);
145
152 void setConfigurationValue(const std::string& key, const SBAny& value);
153
160 void registerProperty(const std::string& key, const SBAnyMap& propertyInfo);
161
168 void registerAction(const std::string& key, const SBAnyMap& actionInfo);
169
176 void registerEvent(const std::string& eventName, const SBAnyMap& eventInfo);
177
178private:
179 class Impl;
180 std::unique_ptr<Impl> impl;
181};
182
183}
EventEmitter()
Constructor for the EventEmitter class.
~SwitchboardObject() override
SwitchboardObject destructor.
void setObjectID(const std::string &objectID)
Sets the ID of the object.
void setConfigurationValue(const std::string &key, const SBAny &value)
Sets a configuration value for the object.
std::string getObjectType() const
Gets the type of the object.
std::optional< std::string > getObjectSubtype() const
Gets the subtype of the object.
SwitchboardObject(const std::string &objectType)
SwitchboardObject constructor.
void registerConfiguration(const std::string &key, const SBAnyMap &configuration)
Registers a configuration for the object.
void registerEvent(const std::string &eventName, const SBAnyMap &eventInfo)
Registers an event for the object.
void registerProperty(const std::string &key, const SBAnyMap &propertyInfo)
Registers a property for the object.
virtual Result< void > setValue(const std::string &key, const SBAny &value)
Sets a value on the object.
std::string getURI()
Gets the URI of the object.
std::string getObjectID() const
Gets the ID of the object.
virtual Result< SBAny > getValue(const std::string &key)
Gets a value from the object.
void registerAction(const std::string &key, const SBAnyMap &actionInfo)
Registers an action for the object.
SwitchboardObject * getParentObject() const
Gets the parent object of the object.
virtual Result< SBAny > callAction(const std::string &actionName, const SBAnyMap &params)
Calls an action on the object.
void setObjectSubtype(std::optional< std::string > subtype)
Sets the subtype of the object.
void setParentObject(SwitchboardObject *parentObject)
Sets the parent object of the object.