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_core/EventEmitter.hpp>
11#include <switchboard_core/SwitchboardCore.hpp>
12#include <switchboard_core/Configuration.hpp>
13#include <switchboard_core/Property.hpp>
14#include <switchboard_core/Action.hpp>
15#include <switchboard_core/Event.hpp>
16
17#include <any>
18#include <map>
19#include <memory>
20#include <string>
21#include <switchboard/Result.hpp>
22
23namespace switchboard {
24
25namespace SwitchboardObjectType {
26 inline constexpr const char* SWITCHBOARD = "switchboard";
27 inline constexpr const char* ENGINE = "engine";
28 inline constexpr const char* GRAPH = "graph";
29 inline constexpr const char* NODE = "node";
30 inline constexpr const char* EXTENSION = "extension";
31}
32
37public:
38
44 explicit SwitchboardObject(const std::string& objectType);
45
50
56 std::string getObjectID() const;
57
63 void setObjectID(const std::string& objectID);
64
70 std::string getObjectType() const;
71
78
85
94 virtual Result<void> setValue(const std::string& key, const std::any& value);
95
103 virtual Result<std::any> getValue(const std::string& key);
104
113 virtual Result<std::any> callAction(const std::string& actionName, const std::map<std::string, std::any>& params);
114
121 void registerConfiguration(const std::string& key, const std::map<std::string, std::any>& configuration);
122
129 void setConfigurationValue(const std::string& key, const std::any& value);
130
137 void registerProperty(const std::string& key, const std::map<std::string, std::any>& propertyInfo);
138
145 void registerAction(const std::string& key, const std::map<std::string, std::any>& actionInfo);
146
153 void registerEvent(const std::string& eventName, const std::map<std::string, std::any>& eventInfo);
154
155private:
156 class Impl;
157 std::unique_ptr<Impl> impl;
158};
159
160}
EventEmitter()
Constructor for the EventEmitter class.
~SwitchboardObject() override
SwitchboardObject destructor.
void setObjectID(const std::string &objectID)
Sets the ID of the object.
std::string getObjectType() const
Gets the type of the object.
SwitchboardObject(const std::string &objectType)
SwitchboardObject constructor.
virtual Result< void > setValue(const std::string &key, const std::any &value)
Sets a value on the object.
void setConfigurationValue(const std::string &key, const std::any &value)
Sets a configuration value for the object.
void registerAction(const std::string &key, const std::map< std::string, std::any > &actionInfo)
Registers an action for the object.
std::string getObjectID() const
Gets the ID of the object.
void registerConfiguration(const std::string &key, const std::map< std::string, std::any > &configuration)
Registers a configuration for the object.
void registerEvent(const std::string &eventName, const std::map< std::string, std::any > &eventInfo)
Registers an event for the object.
void registerProperty(const std::string &key, const std::map< std::string, std::any > &propertyInfo)
Registers a property for the object.
virtual Result< std::any > callAction(const std::string &actionName, const std::map< std::string, std::any > &params)
Calls an action on the object.
virtual Result< std::any > getValue(const std::string &key)
Gets a value from the object.
SwitchboardObject * getParentObject() const
Gets the parent object of the object.
void setParentObject(SwitchboardObject *parentObject)
Sets the parent object of the object.