diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-06-20 21:26:13 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-06-20 21:26:13 +0900 |
commit | d2ea0d3f12d8c9708071d921f543e64b4252cfd1 (patch) | |
tree | b46e88406d25d93e2dd6b168f12ee82ca22d3283 | |
parent | 64643feb50a184030a6f25ba9354d5fe41df49c8 (diff) |
Move event info queue into PolicyManager
Change-Id: I54a1bd129f396937c3e89bebf02b47c8f610db77
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r-- | src/policy_manager/policy_manager.cpp | 20 | ||||
-rw-r--r-- | src/policy_manager/policy_manager.hpp | 9 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp index 448c18d..fb468df 100644 --- a/src/policy_manager/policy_manager.cpp +++ b/src/policy_manager/policy_manager.cpp @@ -20,7 +20,6 @@ #include <istream> #include <thread> #include <map> -#include <queue> #include <systemd/sd-event.h> #include <json-c/json.h> #include "policy_manager.hpp" @@ -59,17 +58,10 @@ typedef struct CarElement { int changed; } CarElement; -typedef struct EventInfo { - int event; - std::string role; - uint64_t delay; -} EventInfo; - struct sd_event* event_loop; std::map<int, struct sd_event_source*> event_source_list; std::map<int, std::string> g_req_role_list; PolicyManager::CallbackTable callback; -std::queue<EventInfo> g_event_info_queue; std::unordered_map<std::string, CarElement> g_prv_car_elements; std::unordered_map<std::string, CarElement> g_crr_car_elements; @@ -751,7 +743,7 @@ int PolicyManager::setInputEventData(json_object* json_in) { } // Set event info to the queue - pm::EventInfo event_info; + EventInfo event_info; event_info.event = (event_no | category_no | area_no); if (nullptr == role) { event_info.role = std::string(""); @@ -760,7 +752,7 @@ int PolicyManager::setInputEventData(json_object* json_in) { event_info.role = std::string(role); } event_info.delay = 0; - pm::g_event_info_queue.push(event_info); + this->event_info_queue.push(event_info); return 0; } @@ -769,12 +761,12 @@ int PolicyManager::executeStateTransition() { HMI_DEBUG("wm:pm", "Call"); int ret; - pm::EventInfo event_info; + EventInfo event_info; - while (!pm::g_event_info_queue.empty()) { + while (!this->event_info_queue.empty()) { // Get event info from queue and delete - event_info = pm::g_event_info_queue.front(); - pm::g_event_info_queue.pop(); + event_info = this->event_info_queue.front(); + this->event_info_queue.pop(); // Set event info for checking policy ret = checkPolicyEntry(event_info.event, event_info.delay, event_info.role); diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp index 6233a77..fd7314c 100644 --- a/src/policy_manager/policy_manager.hpp +++ b/src/policy_manager/policy_manager.hpp @@ -20,6 +20,7 @@ #include <unordered_map> #include <vector> +#include <queue> struct json_object; @@ -52,6 +53,12 @@ private: PolicyManager(PolicyManager &&) = delete; PolicyManager &operator=(PolicyManager &&) = delete; + typedef struct EventInfo { + int event; + std::string role; + uint64_t delay; + } EventInfo; + // Convert map std::unordered_map<std::string, int> eventname2no; std::unordered_map<std::string, int> categoryname2no; @@ -61,6 +68,8 @@ private: std::unordered_map<std::string, std::string> category2role; std::unordered_map<std::string, std::string> role2defaultarea; + std::queue<EventInfo> event_info_queue; + void initializeLocalState(); int initializeSdEventLoop(); |