EII ConfigMgr C/C++ Reference
app_cfg.hpp
Go to the documentation of this file.
1 // Copyright (c) 2020 Intel Corporation.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
21 
27 #ifndef _EII_CH_APP_CFG_H
28 #define _EII_CH_APP_CFG_H
29 
30 #include <string.h>
31 #include <cjson/cJSON.h>
32 #include <iostream>
33 #include <string>
34 #include <vector>
35 #include <bits/stdc++.h>
36 #include <safe_lib.h>
37 #include <eii/utils/logger.h>
38 #include "eii/utils/json_config.h"
39 #include "eii/config_manager/kv_store_plugin/kv_store_plugin.h"
41 
42 
43 namespace eii {
44  namespace config_manager {
45 
49  class AppCfg {
50  private:
51 
52  // App's config
53  config_t* m_app_config;
54 
55  // App's interface
56  config_t* m_app_interface;
57 
58  // App's data store
59  config_t* m_app_data_store;
60 
61  // cfgmgr_ctx_t object
62  cfgmgr_ctx_t* m_cfgmgr;
63 
67  AppCfg(const AppCfg& src);
68 
72  AppCfg& operator=(const AppCfg& src);
73 
74  protected:
75 
82  std::vector<std::string> tokenizer(const char* str,
83  const char* delim);
84 
85  public:
86 
93  explicit AppCfg(cfgmgr_ctx_t* cfgmgr);
94 
100  config_t* getConfig();
101 
106  config_t* getInterface();
107 
113  config_value_t* getConfigValue(const char* key);
114 
122  bool watch(const char* key, cfgmgr_watch_callback_t watch_callback, void* user_data);
123 
131  bool watchPrefix(char* prefix, cfgmgr_watch_callback_t watch_callback, void* user_data);
132 
139  bool watchConfig(cfgmgr_watch_callback_t watch_callback, void* user_data);
140 
147  bool watchInterface(cfgmgr_watch_callback_t watch_callback, void* user_data);
148 
154  virtual config_t* getMsgBusConfig();
155 
161  virtual std::string getEndpoint();
162 
169  virtual config_value_t* getInterfaceValue(const char* key);
170 
176  virtual std::vector<std::string> getTopics();
177 
185  virtual bool setTopics(std::vector<std::string> topics_list);
186 
192  virtual std::vector<std::string> getAllowedClients();
193 
197  virtual ~AppCfg();
198  };
199  }
200 }
201 #endif
eii::config_manager::AppCfg::getAllowedClients
virtual std::vector< std::string > getAllowedClients()
eii::config_manager::AppCfg::watchInterface
bool watchInterface(cfgmgr_watch_callback_t watch_callback, void *user_data)
eii::config_manager::AppCfg::getInterfaceValue
virtual config_value_t * getInterfaceValue(const char *key)
eii::config_manager::AppCfg::watchConfig
bool watchConfig(cfgmgr_watch_callback_t watch_callback, void *user_data)
eii::config_manager::AppCfg::getTopics
virtual std::vector< std::string > getTopics()
eii::config_manager::AppCfg::setTopics
virtual bool setTopics(std::vector< std::string > topics_list)
cfgmgr_ctx_t
Definition: cfgmgr.h:58
eii::config_manager::AppCfg::getConfigValue
config_value_t * getConfigValue(const char *key)
eii::config_manager::AppCfg::getConfig
config_t * getConfig()
eii::config_manager::AppCfg::tokenizer
std::vector< std::string > tokenizer(const char *str, const char *delim)
eii::config_manager::AppCfg::watchPrefix
bool watchPrefix(char *prefix, cfgmgr_watch_callback_t watch_callback, void *user_data)
eii::config_manager::AppCfg::getInterface
config_t * getInterface()
eii::config_manager::AppCfg::getEndpoint
virtual std::string getEndpoint()
eii::config_manager::AppCfg::~AppCfg
virtual ~AppCfg()
cfgmgr.h
Configuration Manager C APIs.
eii::config_manager::AppCfg::getMsgBusConfig
virtual config_t * getMsgBusConfig()
eii::config_manager::AppCfg::watch
bool watch(const char *key, cfgmgr_watch_callback_t watch_callback, void *user_data)
eii::config_manager::AppCfg
Definition: app_cfg.hpp:49