nx_metadata_sdk 1.0 Metadata SDK

i_engine.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <nx/sdk/i_active_setting_changed_action.h>
6 #include <nx/sdk/i_active_setting_changed_response.h>
7 #include <nx/sdk/i_device_info.h>
8 #include <nx/sdk/i_plugin_diagnostic_event.h>
9 #include <nx/sdk/i_settings_response.h>
10 #include <nx/sdk/i_string.h>
11 #include <nx/sdk/interface.h>
12 #include <nx/sdk/result.h>
13
14 #include "i_action.h"
15 #include "i_device_agent.h"
16 #include "i_engine_info.h"
17
18 namespace nx::sdk::analytics {
19
20 class IPlugin; //< Forward declaration for the parent object.
21
22 class IEngine0: public Interface<IEngine0>
23 {
24 public:
25 static auto interfaceId() { return makeId("nx::sdk::analytics::IEngine"); }
26
27 class IHandler: public Interface<IHandler>
28 {
29 public:
30 static auto interfaceId() { return makeId("nx::sdk::analytics::IEngine::IHandler"); }
31
32 virtual ~IHandler() = default;
33 virtual void handlePluginDiagnosticEvent(IPluginDiagnosticEvent* event) = 0;
34 };
35
40 virtual void setEngineInfo(const IEngineInfo* engineInfo) = 0;
41
43 protected: virtual void doSetSettings(
44 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) = 0;
60 public: Result<const ISettingsResponse*> setSettings(const IStringMap* settings)
61 {
62 Result<const ISettingsResponse*> result;
63 doSetSettings(&result, settings);
64 return result;
65 }
66
68 protected: virtual void getPluginSideSettings(
69 Result<const ISettingsResponse*>* outResult) const = 0;
81 public: Result<const ISettingsResponse*> pluginSideSettings() const
82 {
83 Result<const ISettingsResponse*> result;
84 getPluginSideSettings(&result);
85 return result;
86 }
87
89 protected: virtual void getManifest(Result<const IString*>* outResult) const = 0;
102 public: Result<const IString*> manifest() const
103 {
104 Result<const IString*> result;
105 getManifest(&result);
106 return result;
107 }
108
113 virtual bool isCompatible(const IDeviceInfo* deviceInfo) const = 0;
114
116 protected: virtual void doObtainDeviceAgent(
117 Result<IDeviceAgent*>* outResult, const IDeviceInfo* deviceInfo) = 0;
128 public: Result<IDeviceAgent*> obtainDeviceAgent(const IDeviceInfo* deviceInfo)
129 {
130 Result<IDeviceAgent*> result;
131 doObtainDeviceAgent(&result, deviceInfo);
132 return result;
133 }
134
136 protected: virtual void doExecuteAction(
137 Result<IAction::Result>* outResult, const IAction* action) = 0;
145 public: Result<IAction::Result> executeAction(const IAction* action)
146 {
147 Result<IAction::Result> result;
148 doExecuteAction(&result, action);
149 return result;
150 }
151
156 virtual void setHandler(IHandler* handler) = 0;
157 };
158
172 class IEngine: public Interface<IEngine, IEngine0>
173 {
174 public:
175 static auto interfaceId() { return makeId("nx::sdk::analytics::IEngine1"); }
176
178 protected: virtual void doGetSettingsOnActiveSettingChange(
179 Result<const IActiveSettingChangedResponse*>* outResult,
180 const IActiveSettingChangedAction* activeSettingChangedAction) = 0;
192 public: Result<const IActiveSettingChangedResponse*> getSettingsOnActiveSettingChange(
193 const IActiveSettingChangedAction* activeSettingChangedAction)
194 {
195 Result<const IActiveSettingChangedResponse*> result;
196 doGetSettingsOnActiveSettingChange(&result, activeSettingChangedAction);
197 return result;
198 }
199 };
200 using IEngine1 = IEngine;
201
202 } // namespace nx::sdk::analytics
nx::sdk::IPluginDiagnosticEvent
Definition: i_plugin_diagnostic_event.h:13
nx::sdk::analytics::IEngine0::executeAction
Result< IAction::Result > executeAction(const IAction *action)
Definition: i_engine.h:145
nx::sdk::analytics::IEngine0::setEngineInfo
virtual void setEngineInfo(const IEngineInfo *engineInfo)=0
nx::sdk::IStringMap
Definition: i_string_map.h:9
nx::sdk::analytics::IEngine0::doExecuteAction
virtual void doExecuteAction(Result< IAction::Result > *outResult, const IAction *action)=0
nx::sdk::IActiveSettingChangedAction
Definition: i_active_setting_changed_action.h:14
nx::sdk::analytics::IEngine0::doSetSettings
virtual void doSetSettings(Result< const ISettingsResponse *> *outResult, const IStringMap *settings)=0
nx::sdk::Interface
Definition: interface.h:48
nx::sdk::analytics::IAction
Definition: i_action.h:17
nx::sdk::analytics::IEngine0::setSettings
Result< const ISettingsResponse * > setSettings(const IStringMap *settings)
Definition: i_engine.h:60
nx::sdk::analytics::IEngine0::manifest
Result< const IString * > manifest() const
Definition: i_engine.h:102
nx::sdk::analytics::IEngine0::getPluginSideSettings
virtual void getPluginSideSettings(Result< const ISettingsResponse *> *outResult) const =0
nx::sdk::analytics::IEngine0::IHandler
Definition: i_engine.h:27
nx::sdk::analytics::IEngine0::setHandler
virtual void setHandler(IHandler *handler)=0
nx::sdk::analytics::IEngine
Definition: i_engine.h:172
nx::sdk::analytics
Definition: consuming_device_agent.cpp:24
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:48
nx::sdk::analytics::IEngineInfo
Definition: i_engine_info.h:10
nx::sdk::analytics::IEngine::getSettingsOnActiveSettingChange
Result< const IActiveSettingChangedResponse * > getSettingsOnActiveSettingChange(const IActiveSettingChangedAction *activeSettingChangedAction)
Definition: i_engine.h:192
nx::sdk::analytics::IEngine0::doObtainDeviceAgent
virtual void doObtainDeviceAgent(Result< IDeviceAgent *> *outResult, const IDeviceInfo *deviceInfo)=0
nx::sdk::analytics::IEngine::doGetSettingsOnActiveSettingChange
virtual void doGetSettingsOnActiveSettingChange(Result< const IActiveSettingChangedResponse *> *outResult, const IActiveSettingChangedAction *activeSettingChangedAction)=0
nx::sdk::analytics::IEngine0::getManifest
virtual void getManifest(Result< const IString *> *outResult) const =0
nx::sdk::analytics::IEngine0::obtainDeviceAgent
Result< IDeviceAgent * > obtainDeviceAgent(const IDeviceInfo *deviceInfo)
Definition: i_engine.h:128
nx::sdk::analytics::IEngine0::isCompatible
virtual bool isCompatible(const IDeviceInfo *deviceInfo) const =0
nx::sdk::analytics::IEngine0
Definition: i_engine.h:22
nx::sdk::analytics::IEngine0::pluginSideSettings
Result< const ISettingsResponse * > pluginSideSettings() const
Definition: i_engine.h:81
nx::sdk::IRefCountable::makeId
static const InterfaceId * makeId(const char(&charArray)[len])
Definition: i_ref_countable.h:77