nx_server_plugin_sdk 1.0 Server Plugin SDK

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 <map>
6 #include <mutex>
7 #include <string>
8
9 #include <nx/sdk/analytics/i_engine.h>
10 #include <nx/sdk/helpers/log_utils.h>
11 #include <nx/sdk/helpers/ref_countable.h>
12 #include <nx/sdk/i_string_map.h>
13 #include <nx/sdk/ptr.h>
14 #include <nx/sdk/result.h>
15 #include <nx/sdk/uuid.h>
16
17 namespace nx::sdk::analytics {
18
31 class Engine: public RefCountable<IEngine>
32 {
33 protected:
34 LogUtils logUtils;
35
36 protected:
42 Engine(bool enableOutput, const std::string& integrationInstanceId = "");
43
44 virtual std::string manifestString() const = 0;
45
51 virtual Result<const ISettingsResponse*> settingsReceived() { return nullptr; }
52
62 std::string settingValue(const std::string& settingName) const;
63
72 std::map<std::string, std::string> currentSettings() const;
73
84 virtual Result<IAction::Result> executeAction(
85 const std::string& actionId,
86 Uuid objectTrackId,
87 Uuid deviceId,
88 int64_t timestampUs,
89 Ptr<IObjectTrackInfo> trackInfo,
90 const std::map<std::string, std::string>& params);
91
97 void pushIntegrationDiagnosticEvent(
98 IIntegrationDiagnosticEvent::Level level,
99 std::string caption,
100 std::string description) const;
101
102 IHandler* handler() const { return m_handler.get(); }
103
104 virtual void doGetSettingsOnActiveSettingChange(
105 Result<const IActiveSettingChangedResponse*>* outResult,
106 const IActiveSettingChangedAction* activeSettingChangedAction) override;
107
108 void pushManifest(const std::string& manifest);
109
110 public:
111 virtual ~Engine() override;
112
113 //-------------------------------------------------------------------------------------------------
114 // Not intended to be used by a descendant.
115
116 public:
117 virtual void setEngineInfo(const IEngineInfo* engineInfo) override;
118 virtual void setHandler(IEngine::IHandler* handler) override;
119 virtual bool isCompatible(const IDeviceInfo* deviceInfo) const override;
120
121 protected:
122 virtual void doSetSettings(
123 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) override;
124
125 virtual void getIntegrationSideSettings(Result<const ISettingsResponse*>* outResult) const override;
126
127 virtual void getManifest(Result<const IString*>* outResult) const override;
128
129 virtual void doExecuteAction(
130 Result<IAction::Result>* outResult, const IAction* action) override;
131
132 private:
133 mutable std::mutex m_mutex;
134 std::map<std::string, std::string> m_settings;
135 Ptr<IEngine::IHandler> m_handler;
136 std::string m_integrationInstanceId;
137 };
138
139 } // namespace nx::sdk::analytics
nx::sdk::IStringMap
Definition: i_string_map.h:9
nx::sdk::IActiveSettingChangedAction
Definition: i_active_setting_changed_action.h:14
nx::sdk::analytics::Engine::currentSettings
std::map< std::string, std::string > currentSettings() const
Definition: engine.cpp:55
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::Engine::settingValue
std::string settingValue(const std::string &settingName) const
Definition: engine.cpp:44
nx::sdk::analytics
Definition: consuming_device_agent.cpp:25
nx::sdk::analytics::Engine::pushIntegrationDiagnosticEvent
void pushIntegrationDiagnosticEvent(IIntegrationDiagnosticEvent::Level level, std::string caption, std::string description) const
Definition: engine.cpp:71
nx::sdk::Uuid
Definition: uuid.h:22
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:52
nx::sdk::LogUtils
Definition: log_utils.h:27
nx::sdk::analytics::Engine::executeAction
virtual Result< IAction::Result > executeAction(const std::string &actionId, Uuid objectTrackId, Uuid deviceId, int64_t timestampUs, Ptr< IObjectTrackInfo > trackInfo, const std::map< std::string, std::string > &params)
Definition: engine.cpp:60
nx::sdk::analytics::Engine::settingsReceived
virtual Result< const ISettingsResponse * > settingsReceived()
Definition: engine.h:51
nx::sdk::analytics::Engine
Definition: engine.h:31
nx::sdk::RefCountable
Definition: ref_countable.h:83
nx::sdk::analytics::Engine::Engine
Engine(bool enableOutput, const std::string &integrationInstanceId="")
Definition: engine.cpp:35