diff options
Diffstat (limited to 'src/policy_manager/policy_manager.hpp')
-rw-r--r-- | src/policy_manager/policy_manager.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp index 787a3ec..57856dc 100644 --- a/src/policy_manager/policy_manager.hpp +++ b/src/policy_manager/policy_manager.hpp @@ -23,6 +23,7 @@ struct json_object; +struct sd_event; class PolicyManager { @@ -30,9 +31,13 @@ public: explicit PolicyManager(); ~PolicyManager() = default; + using Handler = std::function<void(json_object *)>; + int initialize(); - int checkPolicy(json_object* json_in, json_object** json_out); + void setEventHandler(PolicyManager::Handler handler); + int inputEvent(json_object* json_in, PolicyManager::Handler notify_state); std::string roleToCategory(const char* role); + private: // Disable copy and move PolicyManager(PolicyManager const &) = delete; @@ -49,14 +54,19 @@ private: std::unordered_map<std::string, std::string> category2role_; std::unordered_map<std::string, std::string> role2defaultarea_; + struct sd_event* sd_event_; + + int initializeSdEventLoop(); + void checkPolicyEntry(int event, int delay_ms, PolicyManager::Handler handler); + // Load role.db int loadRoleDb(); const char* getStringFromJson(json_object* obj, const char* key); int inputJsonFilie(const char* file, json_object** obj); - void addStateToJson(const char* key, int is_changed, const char* state, json_object** json_out); std::vector<std::string> parseString(std::string str, char delimiter); std::string deleteSpace(std::string str); + }; |