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 <atomic>
6 #include <condition_variable>
7 #include <memory>
8 #include <mutex>
9 #include <thread>
10
11 #include <nx/sdk/analytics/helpers/engine.h>
12 #include <nx/sdk/analytics/helpers/integration.h>
13 #include <nx/sdk/analytics/i_uncompressed_video_frame.h>
14 #include <nx/sdk/uuid.h>
15
16 namespace nx {
17 namespace vms_server_plugins {
18 namespace analytics {
19 namespace stub {
20 namespace diagnostic_events {
21
22 const std::string kGenerateIntegrationDiagnosticEventsFromEngineSetting =
23 "generateIntegrationDiagnosticEventsFromEngine";
24
25 class Engine: public nx::sdk::analytics::Engine
26 {
27 public:
28 Engine(nx::sdk::analytics::Integration* integration);
29 virtual ~Engine() override;
30
31 nx::sdk::analytics::Integration* const integration() const { return m_integration; }
32
33 protected:
34 virtual std::string manifestString() const override;
35
36 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
37
38 protected:
39 virtual void doObtainDeviceAgent(
40 nx::sdk::Result<nx::sdk::analytics::IDeviceAgent*>* outResult,
41 const nx::sdk::IDeviceInfo* deviceInfo) override;
42
43 private:
44 void eventThreadLoop();
45 void startEventThread();
46 void stopEventThread();
47
48 private:
49 nx::sdk::analytics::Integration* const m_integration;
50
51 std::unique_ptr<std::thread> m_eventThread;
52 std::mutex m_eventThreadMutex;
53 std::condition_variable m_eventThreadCondition;
54 std::atomic<bool> m_stopping{false};
55 std::atomic<bool> m_terminated{false};
56
57 struct EngineSettings
58 {
59 std::atomic<bool> generateEvents{false};
60 };
61
62 EngineSettings m_engineSettings;
63 };
64
65 } // namespace diagnostic_events
66 } // namespace stub
67 } // namespace analytics
68 } // namespace vms_server_plugins
69 } // namespace nx
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:52
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::diagnostic_events::Engine::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: engine.cpp:81
nx::vms_server_plugins::analytics::stub::diagnostic_events::Engine
Definition: engine.h:25
nx::sdk::analytics::Engine
Definition: engine.h:31
nx::sdk::analytics::Integration
Definition: integration.h:21