nx_metadata_sdk 1.0 Metadata 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:
41 Engine(bool enableOutput, const std::string& pluginInstanceId = "");
42
43 virtual std::string manifestString() const = 0;
44
50 virtual Result<const ISettingsResponse*> settingsReceived() { return nullptr; }
51
61 std::string settingValue(const std::string& settingName) const;
62
71 std::map<std::string, std::string> currentSettings() const;
72
83 virtual Result<IAction::Result> executeAction(
84 const std::string& actionId,
85 Uuid objectTrackId,
86 Uuid deviceId,
87 int64_t timestampUs,
88 Ptr<IObjectTrackInfo> trackInfo,
89 const std::map<std::string, std::string>& params);
90
96 void pushPluginDiagnosticEvent(
97 IPluginDiagnosticEvent::Level level,
98 std::string caption,
99 std::string description) const;
100
101 IHandler* handler() const { return m_handler.get(); }
102
103 virtual void doGetSettingsOnActiveSettingChange(
104 Result<const IActiveSettingChangedResponse*>* outResult,
105 const IActiveSettingChangedAction* activeSettingChangedAction) override;
106
107 public:
108 virtual ~Engine() override;
109
110 //-------------------------------------------------------------------------------------------------
111 // Not intended to be used by a descendant.
112
113 public:
114 virtual void setEngineInfo(const IEngineInfo* engineInfo) override;
115 virtual void setHandler(IEngine::IHandler* handler) override;
116 virtual bool isCompatible(const IDeviceInfo* deviceInfo) const override;
117
118 protected:
119 virtual void doSetSettings(
120 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) override;
121
122 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
123
124 virtual void getManifest(Result<const IString*>* outResult) const override;
125
126 virtual void doExecuteAction(
127 Result<IAction::Result>* outResult, const IAction* action) override;
128
129 private:
130 mutable std::mutex m_mutex;
131 std::map<std::string, std::string> m_settings;
132 Ptr<IEngine::IHandler> m_handler;
133 std::string m_pluginInstanceId;
134 };
135
136 } // 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::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description) const
Definition: engine.cpp:71
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::Engine::Engine
Engine(bool enableOutput, const std::string &pluginInstanceId="")
Definition: engine.cpp:35
nx::sdk::analytics
Definition: consuming_device_agent.cpp:24
nx::sdk::Uuid
Definition: uuid.h:22
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:48
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:50
nx::sdk::analytics::Engine
Definition: engine.h:31
nx::sdk::RefCountable
Definition: ref_countable.h:83