EII ConfigMgr C/C++ Reference
cfgmgr.h
Go to the documentation of this file.
1 // Copyright (c) 2021 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 
26 #include <ctype.h>
27 #include "eii/config_manager/kv_store_plugin/kv_store_plugin.h"
29 
30 #define PUBLISHERS "Publishers"
31 #define SUBSCRIBERS "Subscribers"
32 #define SERVERS "Servers"
33 #define CLIENTS "Clients"
34 #define SOCKET_FILE "socket_file"
35 #define ENDPOINT "EndPoint"
36 #define TOPICS "Topics"
37 #define NAME "Name"
38 #define ALLOWED_CLIENTS "AllowedClients"
39 #define TYPE "Type"
40 #define PUBLIC_KEYS "/Publickeys/"
41 #define PRIVATE_KEY "/private_key"
42 #define ZMQ_RECV_HWM "zmq_recv_hwm"
43 #define BROKER_APPNAME "BrokerAppName"
44 #define BROKERED "brokered"
45 #define PUBLISHER_APPNAME "PublisherAppName"
46 #define SERVER_APPNAME "ServerAppName"
47 
48 #ifndef _EII_C_CONFIG_MGR_H
49 #define _EII_C_CONFIG_MGR_H
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef struct {
59 
60  // Holds the list of /GlobalEnv var
61  // to be set in the Go/Py/Cpp bindings
62  char* env_var;
63 
64  // Application config
65  config_t* app_config;
66 
67  // Application interface
68  config_t* app_interface;
69 
70  // Application data store
71  config_t* data_store;
72 
73  // Application AppName
74  char* app_name;
75 
76  // Dev mode variable
77  int dev_mode;
78 
79  // kv_store_client to call kv_store APIs
80  kv_store_client_t* kv_store_client;
81 
82  // kv_store_handle to hold the kv_store object
83  void* kv_store_handle;
84 
85 } cfgmgr_ctx_t;
86 
90 typedef struct {
91 
92  // Holds the interface specific
93  // to a CFGMGR_PUBLISHER/CFGMGR_SUBSCRIBER/
94  // CFGMGR_SERVER/CFGMGR_CLIENT
95  config_value_t* interface;
96 
97  // Defines the type of interface
99 
100  // Holds the cfgmgr context
101  cfgmgr_ctx_t* cfg_mgr;
102 
104 
105 
111 bool cfgmgr_is_dev_mode(cfgmgr_ctx_t* cfgmgr);
112 
118 config_value_t* cfgmgr_get_appname(cfgmgr_ctx_t* cfgmgr);
119 
125 config_t* cfgmgr_get_app_config(cfgmgr_ctx_t* cfgmgr);
126 
132 config_t* cfgmgr_get_app_interface(cfgmgr_ctx_t* cfgmgr);
133 
140 config_value_t* cfgmgr_get_app_config_value(cfgmgr_ctx_t* cfgmgr, const char* key);
141 
148 config_value_t* cfgmgr_get_app_interface_value(cfgmgr_ctx_t* cfgmgr, const char* key);
149 
157 
164 config_value_t* cfgmgr_get_endpoint(cfgmgr_interface_t* ctx);
165 
176 config_value_t* cfgmgr_get_topics(cfgmgr_interface_t* ctx);
177 
185 bool cfgmgr_set_topics(cfgmgr_interface_t* ctx, char const* const* topics_list, int len);
186 
198 config_value_t* cfgmgr_get_allowed_clients(cfgmgr_interface_t* ctx);
199 
206 
213 
220 
227 
228 // cfgmgr callback type to be used in watch APIs
229 typedef kv_store_watch_callback_t cfgmgr_watch_callback_t;
230 
238 void cfgmgr_watch(cfgmgr_ctx_t* cfgmgr, const char* key, cfgmgr_watch_callback_t watch_callback, void* user_data);
239 
247 void cfgmgr_watch_prefix(cfgmgr_ctx_t* cfgmgr, char* prefix, cfgmgr_watch_callback_t watch_callback, void* user_data);
248 
255 config_value_t* cfgmgr_get_interface_value(cfgmgr_interface_t* cfgmgr_interface, const char* key);
256 
264 
272 
280 
288 
295 cfgmgr_interface_t* cfgmgr_get_server_by_name(cfgmgr_ctx_t* cfgmgr, const char* name);
296 
304 
311 cfgmgr_interface_t* cfgmgr_get_client_by_name(cfgmgr_ctx_t* cfgmgr, const char* name);
312 
320 
326 
332 void cfgmgr_destroy(cfgmgr_ctx_t *cfg_mgr);
333 
339 
345 void cfgmgr_interface_destroy(cfgmgr_interface_t *cfg_mgr_interface);
346 
347 #ifdef __cplusplus
348 }
349 #endif
350 
351 #endif
cfgmgr_is_dev_mode
bool cfgmgr_is_dev_mode(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_server_by_name
cfgmgr_interface_t * cfgmgr_get_server_by_name(cfgmgr_ctx_t *cfgmgr, const char *name)
cfgmgr_iface_type_t
cfgmgr_iface_type_t
Definition: cfgmgr_util.h:59
cfgmgr_watch_prefix
void cfgmgr_watch_prefix(cfgmgr_ctx_t *cfgmgr, char *prefix, cfgmgr_watch_callback_t watch_callback, void *user_data)
cfgmgr_set_topics
bool cfgmgr_set_topics(cfgmgr_interface_t *ctx, char const *const *topics_list, int len)
cfgmgr_get_server_by_index
cfgmgr_interface_t * cfgmgr_get_server_by_index(cfgmgr_ctx_t *cfgmgr, int index)
cfgmgr_get_app_interface_value
config_value_t * cfgmgr_get_app_interface_value(cfgmgr_ctx_t *cfgmgr, const char *key)
cfgmgr_get_subscriber_by_name
cfgmgr_interface_t * cfgmgr_get_subscriber_by_name(cfgmgr_ctx_t *cfgmgr, const char *name)
cfgmgr_get_msgbus_config
config_t * cfgmgr_get_msgbus_config(cfgmgr_interface_t *ctx)
cfgmgr_get_num_publishers
int cfgmgr_get_num_publishers(cfgmgr_ctx_t *cfgmgr)
cfgmgr_interface_t
Definition: cfgmgr.h:90
cfgmgr_initialize
cfgmgr_ctx_t * cfgmgr_initialize()
cfgmgr_watch
void cfgmgr_watch(cfgmgr_ctx_t *cfgmgr, const char *key, cfgmgr_watch_callback_t watch_callback, void *user_data)
cfgmgr_destroy
void cfgmgr_destroy(cfgmgr_ctx_t *cfg_mgr)
cfgmgr_ctx_t
Definition: cfgmgr.h:58
cfgmgr_get_appname
config_value_t * cfgmgr_get_appname(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_client_by_name
cfgmgr_interface_t * cfgmgr_get_client_by_name(cfgmgr_ctx_t *cfgmgr, const char *name)
cfgmgr_get_publisher_by_name
cfgmgr_interface_t * cfgmgr_get_publisher_by_name(cfgmgr_ctx_t *cfgmgr, const char *name)
cfgmgr_get_client_by_index
cfgmgr_interface_t * cfgmgr_get_client_by_index(cfgmgr_ctx_t *cfgmgr, int index)
cfgmgr_get_interface_value
config_value_t * cfgmgr_get_interface_value(cfgmgr_interface_t *cfgmgr_interface, const char *key)
cfgmgr_util.h
Utility for ConfigManager.
cfgmgr_get_app_interface
config_t * cfgmgr_get_app_interface(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_num_subscribers
int cfgmgr_get_num_subscribers(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_num_servers
int cfgmgr_get_num_servers(cfgmgr_ctx_t *cfgmgr)
cfgmgr_interface_initialize
cfgmgr_interface_t * cfgmgr_interface_initialize()
cfgmgr_get_app_config_value
config_value_t * cfgmgr_get_app_config_value(cfgmgr_ctx_t *cfgmgr, const char *key)
cfgmgr_get_subscriber_by_index
cfgmgr_interface_t * cfgmgr_get_subscriber_by_index(cfgmgr_ctx_t *cfgmgr, int index)
cfgmgr_get_app_config
config_t * cfgmgr_get_app_config(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_endpoint
config_value_t * cfgmgr_get_endpoint(cfgmgr_interface_t *ctx)
cfgmgr_interface_destroy
void cfgmgr_interface_destroy(cfgmgr_interface_t *cfg_mgr_interface)
cfgmgr_get_num_clients
int cfgmgr_get_num_clients(cfgmgr_ctx_t *cfgmgr)
cfgmgr_get_allowed_clients
config_value_t * cfgmgr_get_allowed_clients(cfgmgr_interface_t *ctx)
cfgmgr_get_publisher_by_index
cfgmgr_interface_t * cfgmgr_get_publisher_by_index(cfgmgr_ctx_t *cfgmgr, int index)
cfgmgr_get_topics
config_value_t * cfgmgr_get_topics(cfgmgr_interface_t *ctx)