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:
43 Engine(bool enableOutput);
44
45 virtual std::string manifestString() const = 0;
46
52 virtual Result<const IStringMap*> settingsReceived() { return nullptr; }
53
63 std::string settingValue(const std::string& settingName);
64
75 virtual Result<IAction::Result> executeAction(
76 const std::string& /*actionId*/,
77 Uuid /*objectTrackId*/,
78 Uuid /*deviceId*/,
79 int64_t /*timestampUs*/,
80 Ptr<IObjectTrackInfo> /*trackInfo*/,
81 const std::map<std::string, std::string>& /*params*/)
82 {
83 return {};
84 }
85
91 void pushPluginDiagnosticEvent(
92 IPluginDiagnosticEvent::Level level,
93 std::string caption,
94 std::string description);
95
96 IHandler* handler() const { return m_handler.get(); }
97
98 public:
99 virtual ~Engine() override;
100
101 //-------------------------------------------------------------------------------------------------
102 // Not intended to be used by a descendant.
103
104 public:
105 virtual void setEngineInfo(const IEngineInfo* engineInfo) override;
106 virtual void setHandler(IEngine::IHandler* handler) override;
107 virtual bool isCompatible(const IDeviceInfo* deviceInfo) const override;
108
109 protected:
110 virtual void doSetSettings(
111 Result<const IStringMap*>* outResult, const IStringMap* settings) override;
112
113 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
114
115 virtual void getManifest(Result<const IString*>* outResult) const override;
116
117 virtual void doExecuteAction(
118 Result<IAction::Result>* outResult, const IAction* action) override;
119
120 private:
121 mutable std::mutex m_mutex;
122 std::map<std::string, std::string> m_settings;
123 Ptr<IEngine::IHandler> m_handler;
124 };
125
126 } // namespace analytics
127 } // namespace sdk
128 } // namespace nx
nx::sdk::IStringMap
Definition: i_string_map.h:10
nx::sdk::analytics::Engine::Engine
Engine(bool enableOutput)
Definition: engine.cpp:32
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::Engine::executeAction
virtual Result< IAction::Result > executeAction(const std::string &, Uuid, Uuid, int64_t, Ptr< IObjectTrackInfo >, const std::map< std::string, std::string > &)
Definition: engine.h:75
nx::sdk::Uuid
Definition: uuid.h:21
nx::sdk::IDeviceInfo
Definition: i_device_info.h:14
nx::sdk::analytics::Engine::settingValue
std::string settingValue(const std::string &settingName)
Definition: engine.cpp:38
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::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description)
Definition: engine.cpp:43
nx::sdk::analytics::Engine::settingsReceived
virtual Result< const IStringMap * > settingsReceived()
Definition: engine.h:52
nx::sdk::analytics::Engine
Definition: engine.h:34
nx::sdk::RefCountable
Definition: ref_countable.h:84