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/ObjectTypeInfo.hpp>
16#include <switchboard_core/Property.hpp>
17#include <switchboard_core/Action.hpp>
18#include <switchboard_core/Event.hpp>
24#include <switchboard/Result.hpp>
26namespace switchboard {
42 { OBJECT_TYPE_FIELD_PROPERTIES,
46 { PROPERTY_FIELD_TYPE, PROPERTY_TYPE_BOOLEAN },
47 { PROPERTY_FIELD_READ_ONLY,
true },
48 { PROPERTY_FIELD_DESCRIPTION,
"Whether the node has actions." },
52 { PROPERTY_FIELD_TYPE, PROPERTY_TYPE_BOOLEAN },
53 { PROPERTY_FIELD_READ_ONLY,
true },
54 { PROPERTY_FIELD_DESCRIPTION,
"Whether the node has events." },
57 { OBJECT_TYPE_FIELD_ACTIONS,
61 { ACTION_FIELD_DESCRIPTION,
62 "Returns the full state of the object including identity, configuration, and current property values." },
66 { ACTION_FIELD_DESCRIPTION,
"Returns the configuration schema for this object." },
70 { ACTION_FIELD_DESCRIPTION,
"Returns the property schema for this object." },
74 { ACTION_FIELD_DESCRIPTION,
"Returns the action schema for this object." },
78 { ACTION_FIELD_DESCRIPTION,
"Returns the event schema for this object." },
160 virtual Result<void>
setValue(
const std::string& key,
const SBAny& value);
169 virtual Result<SBAny>
getValue(
const std::string& key);
179 virtual Result<SBAny>
callAction(
const std::string& actionName,
const SBAnyMap& params);
219 const std::string& key,
220 const SBAnyMap& schema,
221 const SBAny& getter = SBAny(),
222 const SBAny& setter = SBAny()
237 void registerAction(
const std::string& key,
const SBAnyMap& schema, ActionHandler handler = {});
245 void registerEvent(
const std::string& eventName,
const SBAnyMap& eventInfo);
249 std::unique_ptr<Impl> impl;
EventEmitter()
Constructor for the EventEmitter class.
~SwitchboardObject() override
SwitchboardObject destructor.
void registerProperty(const std::string &key, const SBAnyMap &schema, const SBAny &getter=SBAny(), const SBAny &setter=SBAny())
Registers a property for the object.
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 registerEvent(const std::string &eventName, const SBAnyMap &eventInfo)
Registers an event for the object.
void registerAction(const std::string &key, const SBAnyMap &schema, ActionHandler handler={})
Registers an action 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.
static SBAnyMap getObjectTypeInfo()
Static type-info fragment for the SwitchboardObject base. Concrete subtypes should merge this with th...
Definition SwitchboardObject.hpp:40
SwitchboardObject * getParentObject() const
Gets the parent object of 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.
virtual Result< SBAny > callAction(const std::string &actionName, const SBAnyMap ¶ms)
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.