nx_server_plugin_sdk 1.0 Server Plugin SDK

active_settings_builder.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 <functional>
6 #include <map>
7 #include <string>
8
9 #include <nx/kit/json.h>
10 #include <nx/sdk/i_string.h>
11 #include <nx/sdk/i_string_map.h>
12 #include <nx/sdk/result.h>
13
14 namespace nx {
15 namespace vms_server_plugins {
16 namespace analytics {
17 namespace stub {
18 namespace settings {
19
20 class ActiveSettingsBuilder
21 {
22 public:
23 using ActiveSettingHandler = std::function<void(
24 nx::kit::Json* /*inOutModel*/,
25 std::map<std::string, std::string>* /*inOutValues*/)>;
26
27 struct ActiveSettingKey
28 {
29 std::string activeSettingName;
30 std::string activeSettingValue;
31
32 bool operator<(const ActiveSettingKey& other) const;
33 };
34
35 public:
36 ActiveSettingsBuilder() = default;
37
38 void addRule(
39 const std::string& activeSettingName,
40 const std::string& activeSettingValue,
41 ActiveSettingHandler activeSettingHandler);
42
43 void addDefaultRule(
44 const std::string& activeSettingName,
45 ActiveSettingHandler activeSettingHandler);
46
47 void updateSettings(
48 const std::string& activeSettingName,
49 nx::kit::Json* inOutSettingsModel,
50 std::map<std::string, std::string>* inOutSettingsValues) const;
51
52 private:
53 std::map<ActiveSettingKey, ActiveSettingHandler> m_rules;
54 std::map</*activeSettingName*/ std::string, ActiveSettingHandler> m_defaultRules;
55 };
56
57 } // namespace settings
58 } // namespace stub
59 } // namespace analytics
60 } // namespace vms_server_plugins
61 } // namespace nx
nx::vms_server_plugins::analytics::stub::settings::ActiveSettingsBuilder::ActiveSettingKey
Definition: active_settings_builder.h:27
nx::kit::detail::json11::Json
Definition: json.cpp:80
json.h
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::settings::ActiveSettingsBuilder
Definition: active_settings_builder.h:20