nx_metadata_sdk  1.0
Metadata 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 
21 {
22 public:
23  using ActiveSettingHandler = std::function<void(
24  nx::kit::Json* /*inOutModel*/,
25  std::map<std::string, std::string>* /*inOutValues*/)>;
26 
28  {
29  std::string activeSettingId;
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& activeSettingId,
40  const std::string& activeSettingValue,
41  ActiveSettingHandler activeSettingHandler);
42 
43  void addDefaultRule(
44  const std::string& activeSettingId,
45  ActiveSettingHandler activeSettingHandler);
46 
47  void updateSettings(
48  const std::string& activeSettingId,
49  nx::kit::Json* inOutSettingsModel,
50  std::map<std::string, std::string>* inOutSettingsValues);
51 
52 private:
53  std::map<ActiveSettingKey, ActiveSettingHandler> m_rules;
54  std::map</*activeSettingId*/ std::string, ActiveSettingHandler> m_defaultRules;
55 };
56 
57 } // namespace settings
58 } // namespace stub
59 } // namespace analytics
60 } // namespace vms_server_plugins
61 } // namespace nx
Definition: json.cpp:80
Definition: apple_utils.h:6