Fledge
An open source edge computing platform for industrial users
config_handler.h
1 #ifndef _CONFIG_HANDLER_H
2 #define _CONFIG_HANDLER_H
3 /*
4  * Fledge
5  *
6  * Copyright (c) 2018 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 #include <service_handler.h>
13 #include <management_client.h>
14 #include <config_category.h>
15 #include <logger.h>
16 #include <string>
17 #include <map>
18 #include <mutex>
19 
20 typedef std::multimap<std::string, ServiceHandler *> CONFIG_MAP;
21 
26  public:
28  void configChange(const std::string& category, const std::string& config);
29  void configChildCreate(const std::string& parent_category, const std::string& child_category, const std::string& config);
30  void configChildDelete(const std::string& parent_category, const std::string& child_category);
31  void registerCategory(ServiceHandler *handler,
32  const std::string& category);
33  void registerCategoryChild(ServiceHandler *handler, const std::string& category);
34 
35  void unregisterCategory(ServiceHandler *handler, const std::string& category);
36  static ConfigHandler *instance;
37  private:
39  ~ConfigHandler();
40  ManagementClient *m_mgtClient;
41  CONFIG_MAP m_registrations;
42  CONFIG_MAP m_registrationsChild;
43  Logger *m_logger;
44  std::mutex m_mutex;
45  bool m_change;
46 };
47 #endif
Fledge Logger class used to log to syslog.
Definition: logger.h:26
void registerCategoryChild(ServiceHandler *handler, const std::string &category)
Register a service handler for a given configuration category when a children category is changed...
Definition: config_handler.cpp:174
The management client class used by services and tasks to communicate with the management API of the ...
Definition: management_client.h:43
ServiceHandler abstract class - the interface that services using the management API must provide...
Definition: service_handler.h:20
void registerCategory(ServiceHandler *handler, const std::string &category)
Register a service handler for a given configuration category.
Definition: config_handler.cpp:140
void unregisterCategory(ServiceHandler *handler, const std::string &category)
Unregister a configuration category from the ConfigHandler for a particular registered ServiceHandler...
Definition: config_handler.cpp:211
static ConfigHandler * getInstance(ManagementClient *)
ConfigHandler Singleton implementation.
Definition: config_handler.cpp:21
void configChildCreate(const std::string &parent_category, const std::string &child_category, const std::string &config)
Handle a callback from the core to handle the creation of a child category.
Definition: config_handler.cpp:74
void configChildDelete(const std::string &parent_category, const std::string &child_category)
Handle a callback from the core to handle the deletion of a child category.
Definition: config_handler.cpp:107
Handler class within a service to manage configuration changes.
Definition: config_handler.h:25
void configChange(const std::string &category, const std::string &config)
Handle a callback from the core to propagate a configuration category change and propagate that to al...
Definition: config_handler.cpp:46