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 <string>
6 #include <map>
7 #include <mutex>
8
9 #include <nx/sdk/i_string_map.h>
10 #include <nx/sdk/analytics/i_engine.h>
11
12 #include <nx/sdk/result.h>
13 #include <nx/sdk/uuid.h>
14
15 #include <nx/sdk/helpers/ref_countable.h>
16 #include <nx/sdk/ptr.h>
17 #include <nx/sdk/helpers/log_utils.h>
18
19 namespace nx {
20 namespace sdk {
21 namespace analytics {
22
34 class Engine: public RefCountable<IEngine>
35 {
36 protected:
37 LogUtils logUtils;
38
39 protected:
44 Engine(bool enableOutput, const std::string& pluginInstanceId = "");
45
46 virtual std::string manifestString() const = 0;
47
53 virtual Result<const ISettingsResponse*> settingsReceived() { return nullptr; }
54
64 std::string settingValue(const std::string& settingName) const;
65
76 virtual Result<IAction::Result> executeAction(
77 const std::string& actionId,
78 Uuid objectTrackId,
79 Uuid deviceId,
80 int64_t timestampUs,
81 Ptr<IObjectTrackInfo> trackInfo,
82 const std::map<std::string, std::string>& params);
83
89 void pushPluginDiagnosticEvent(
90 IPluginDiagnosticEvent::Level level,
91 std::string caption,
92 std::string description);
93
94 IHandler* handler() const { return m_handler.get(); }
95
96 public:
97 virtual ~Engine() override;
98
99 //-------------------------------------------------------------------------------------------------
100 // Not intended to be used by a descendant.
101
102 public:
103 virtual void setEngineInfo(const IEngineInfo* engineInfo) override;
104 virtual void setHandler(IEngine::IHandler* handler) override;
105 virtual bool isCompatible(const IDeviceInfo* deviceInfo) const override;
106
107 protected:
108 virtual void doSetSettings(
109 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) override;
110
111 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
112
113 virtual void getManifest(Result<const IString*>* outResult) const override;
114
115 virtual void doExecuteAction(
116 Result<IAction::Result>* outResult, const IAction* action) override;
117
118 private:
119 mutable std::mutex m_mutex;
120 std::map<std::string, std::string> m_settings;
121 Ptr<IEngine::IHandler> m_handler;
122 std::string m_pluginInstanceId;
123 };
124
125 } // namespace analytics
126 } // namespace sdk
127 } // namespace nx
nx::sdk::IStringMap
Definition: i_string_map.h:10
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::Engine::settingValue
std::string settingValue(const std::string &settingName) const
Definition: engine.cpp:45
nx::sdk::analytics::Engine::Engine
Engine(bool enableOutput, const std::string &pluginInstanceId="")
Definition: engine.cpp:36
nx::sdk::Uuid
Definition: uuid.h:22
nx::sdk::IDeviceInfo
Definition: i_device_info.h:14
nx::sdk::Result
Definition: result.h:47
nx
Definition: apple_utils.h:6
nx::sdk::LogUtils
Definition: log_utils.h:26
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:56
nx::sdk::analytics::Engine::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description)
Definition: engine.cpp:67
nx::sdk::analytics::Engine::settingsReceived
virtual Result< const ISettingsResponse * > settingsReceived()
Definition: engine.h:53
nx::sdk::analytics::Engine
Definition: engine.h:34
nx::sdk::RefCountable
Definition: ref_countable.h:84