From d78ae3cd8f316d1830cde4d611b8e42f90dbcc11 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 7 Jun 2018 15:40:27 +0900 Subject: Format source code Fix character case for * wm-client * wm-error * applist app doesn't complete formating character Change-Id: I7187d7be8bcf158664c4e8e2b090fe4ca7017d12 Signed-off-by: Kazumasa Mitsunari --- src/applist.cpp | 76 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/applist.cpp') diff --git a/src/applist.cpp b/src/applist.cpp index 8c13f5f..bdb64a9 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -20,7 +20,6 @@ using std::shared_ptr; using std::string; -using std::unique_ptr; using std::vector; namespace wm @@ -28,8 +27,8 @@ namespace wm AppList::AppList() : req_list(0), - client_list(0), - current_seq(1) + app2client(0), + current_req(1) { } @@ -38,32 +37,32 @@ AppList::~AppList() {} void AppList::addClient(const string &appid, const string &role) { shared_ptr client = std::make_shared(appid, role); - client_list[appid] = client; - client_dump(); + this->app2client[appid] = client; + this->clientDump(); } void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) { shared_ptr client = std::make_shared(appid, layer, surface, role); - client_list[appid] = client; - client_dump(); + this->app2client[appid] = client; + this->clientDump(); } void AppList::removeClient(const string &appid) { - client_list.erase(appid); + this->app2client.erase(appid); } bool AppList::contains(const string &appid) { - auto result = client_list.find(appid); - return (client_list.end() != result) ? true : false; + auto result = this->app2client.find(appid); + return (this->app2client.end() != result) ? true : false; } void AppList::removeSurface(unsigned surface_id){ // This function may be very slow bool ret = false; - for (auto &x : client_list) + for (auto &x : this->app2client) { ret = x.second->removeSurfaceIfExist(surface_id); if(ret){ @@ -81,23 +80,23 @@ void AppList::removeSurface(unsigned surface_id){ */ shared_ptr AppList::lookUpClient(const string &appid) { - return client_list.at(appid); + return this->app2client.at(appid); } int AppList::countClient() { - return client_list.size(); + return this->app2client.size(); } unsigned AppList::currentSequenceNumber() { - return current_seq; + return this->current_req; } // Is this function necessary ? unsigned AppList::getSequenceNumber(const string &appid) { - for (const auto &x : req_list) + for (const auto &x : this->req_list) { // Since app will not request twice and more, comparing appid is enough? if ((x.trigger.appid == appid)) @@ -110,27 +109,27 @@ unsigned AppList::getSequenceNumber(const string &appid) unsigned AppList::addAllocateRequest(WMRequest req) { - if (req_list.size() == 0) + if (this->req_list.size() == 0) { - req.seq_num = current_seq; + req.seq_num = current_req; } else { - HMI_SEQ_DEBUG(current_seq, "real: %d", req_list.back().seq_num + 1); - req.seq_num = req_list.back().seq_num + 1; + HMI_SEQ_DEBUG(this->current_req, "add: %d", this->req_list.back().seq_num + 1); + req.seq_num = this->req_list.back().seq_num + 1; } - req_list.push_back(req); + this->req_list.push_back(req); return req.seq_num; // return 1; if you test time_expire } bool AppList::requestFinished() { - return req_list.empty(); + return this->req_list.empty(); } struct WMTrigger AppList::getRequest(unsigned req_num) { - for (auto &x : req_list) + for (auto &x : this->req_list) { if (req_num == x.seq_num) { @@ -141,7 +140,7 @@ struct WMTrigger AppList::getRequest(unsigned req_num) const vector &AppList::getActions(unsigned req_num) { - for (auto &x : req_list) + for (auto &x : this->req_list) { if (req_num == x.seq_num) { @@ -153,7 +152,7 @@ const vector &AppList::getActions(unsigned req_num) bool AppList::setAction(unsigned req_num, const struct WMAction &action) { bool result = false; - for (auto &x : req_list) + for (auto &x : this->req_list) { if (req_num != x.seq_num) { @@ -176,7 +175,8 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol { continue; } - WMAction action{appid, role, area, visible, false}; + bool edraw_f = false; + WMAction action{appid, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); result = true; @@ -206,7 +206,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st } } } - req_dump(); + this->reqDump(); return result; } @@ -242,30 +242,30 @@ bool AppList::endDrawFullfilled(unsigned req_num) void AppList::removeRequest(unsigned req_seq) { - req_list.erase(remove_if(req_list.begin(), req_list.end(), - [req_seq](WMRequest x) { - return x.seq_num == req_seq; - })); + this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(), + [req_seq](WMRequest x) { + return x.seq_num == req_seq; + })); } void AppList::next() { - ++this->current_seq; - if (0 == this->current_seq) + ++this->current_req; + if (0 == this->current_req) { - this->current_seq = 1; + this->current_req = 1; } } bool AppList::haveRequest() { - return !req_list.empty(); + return !this->req_list.empty(); } -void AppList::client_dump() +void AppList::clientDump() { DUMP("======= client dump ====="); - for (const auto &x : client_list) + for (const auto &x : this->app2client) { const auto &y = x.second; y->dumpInfo(); @@ -273,10 +273,10 @@ void AppList::client_dump() DUMP("======= client dump end====="); } -void AppList::req_dump() +void AppList::reqDump() { DUMP("======= req dump ====="); - DUMP("current request : %d", current_seq); + DUMP("current request : %d", current_req); for (const auto &x : req_list) { DUMP("requested with : %d", x.seq_num); -- cgit 1.2.3-korg From 46d1ad85e8a4531dcb7dc9599f6c09554e2cdfbb Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 8 Jun 2018 00:08:11 +0900 Subject: Insert hack code to compatible split mode Change-Id: Iaf1769493979637f62e26c4db63b5cd205b13f7b Signed-off-by: Kazumasa Mitsunari --- src/app.cpp | 8 ++++++++ src/applist.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/applist.cpp') diff --git a/src/app.cpp b/src/app.cpp index 1645bfe..e9f6d92 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -758,6 +758,14 @@ void App::lm_layout_change(const char *drawing_name) std::string str_area_sub = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaSub); compositor::rect area_rect_main = this->area_info[state.main]; compositor::rect area_rect_sub = this->area_info[*surface_id]; + // >>> HACK + HMI_WARNING("wm", "HACK!!!"); + std::string hack_appid = "hack"; + std::string hack_role = main; + std::string hack_area = str_area_main; + g_app_list.setAction(g_app_list.currentSequenceNumber(), hack_appid, hack_role, hack_area, true); + g_app_list.setEndDrawFinished(g_app_list.currentSequenceNumber(), hack_appid, hack_role); // This process is illegal + // >>> HACK this->emit_syncdraw(main.c_str(), str_area_main.c_str(), area_rect_main.x, area_rect_main.y, area_rect_main.w, area_rect_main.h); diff --git a/src/applist.cpp b/src/applist.cpp index bdb64a9..66289ea 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -166,6 +166,13 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) return result; } +/** + * Note: + * This function set action with parameters. + * if visible is true, it means app should be visible, so enddraw_finished parameter should be false. + * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true. + * This function doesn't support actions for focus yet. + */ bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible) { bool result = false; @@ -175,7 +182,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol { continue; } - bool edraw_f = false; + bool edraw_f = (visible) ? false : true; WMAction action{appid, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); -- cgit 1.2.3-korg From 9cfdd8937209e3e47b551e7a188add100cbae2e7 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 8 Jun 2018 00:23:01 +0900 Subject: Change names. Not use sequence number but request number * AppList API * Member variable(Not use sequence) Change-Id: Ie0d3d0394c5e050e894b11a91aab97f5bac73f00 Signed-off-by: Kazumasa Mitsunari --- src/app.cpp | 60 ++++++++++++++++++++++++++++----------------------------- src/app.hpp | 4 ++-- src/applist.cpp | 45 ++++++++++++++++++++++++------------------- src/applist.hpp | 4 ++-- src/request.cpp | 4 ++-- src/request.hpp | 2 +- 6 files changed, 62 insertions(+), 57 deletions(-) (limited to 'src/applist.cpp') diff --git a/src/app.cpp b/src/app.cpp index e9f6d92..386524d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -120,10 +120,10 @@ processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata) void App::timerHandler() { - unsigned seq = g_app_list.currentSequenceNumber(); - HMI_SEQ_DEBUG(seq, "Timer expired remove Request"); + unsigned req_num = g_app_list.currentRequestNumber(); + HMI_SEQ_DEBUG(req_num, "Timer expired remove Request"); g_app_list.reqDump(); - g_app_list.removeRequest(seq); + g_app_list.removeRequest(req_num); g_app_list.next(); g_app_list.reqDump(); if (g_app_list.haveRequest()) @@ -423,7 +423,7 @@ void App::layout_commit() void App::set_timer() { - HMI_SEQ_DEBUG(g_app_list.currentSequenceNumber(), "Timer set activate"); + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate"); if (g_timer_ev_src == nullptr) { // firsttime set into sd_event @@ -444,19 +444,19 @@ void App::set_timer() void App::stop_timer() { - unsigned seq = g_app_list.currentSequenceNumber(); - HMI_SEQ_DEBUG(seq, "Timer stop"); + unsigned req_num = g_app_list.currentRequestNumber(); + HMI_SEQ_DEBUG(req_num, "Timer stop"); int rc = sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_OFF); if (rc < 0) { - HMI_SEQ_ERROR(seq, "Timer stop failed"); + HMI_SEQ_ERROR(req_num, "Timer stop failed"); } } bool App::lm_release(const struct WMAction &action) { //auto const &surface_id = this->lookup_id(drawing_name); - unsigned req_num = g_app_list.currentSequenceNumber(); + unsigned req_num = g_app_list.currentRequestNumber(); auto const &surface_id = this->lookup_id(action.role.c_str()); if (!surface_id) { @@ -558,7 +558,7 @@ bool App::lm_layout_change(const struct WMAction &action) TODO: emit syncDraw with application*/ if (msg) { - HMI_SEQ_DEBUG(g_app_list.currentSequenceNumber(), msg); + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), msg); //g_app_list.removeRequest(req_num); return false; } @@ -644,7 +644,7 @@ bool App::do_transition(unsigned req_num) if (!ret) { - //this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test + //this->emit_error(req_num, 0 /*error_num*/, "error happens"); // test } else if (ret && sync_draw_happen) { @@ -763,8 +763,8 @@ void App::lm_layout_change(const char *drawing_name) std::string hack_appid = "hack"; std::string hack_role = main; std::string hack_area = str_area_main; - g_app_list.setAction(g_app_list.currentSequenceNumber(), hack_appid, hack_role, hack_area, true); - g_app_list.setEndDrawFinished(g_app_list.currentSequenceNumber(), hack_appid, hack_role); // This process is illegal + g_app_list.setAction(g_app_list.currentRequestNumber(), hack_appid, hack_role, hack_area, true); + g_app_list.setEndDrawFinished(g_app_list.currentRequestNumber(), hack_appid, hack_role); // This process is illegal // >>> HACK this->emit_syncdraw(main.c_str(), str_area_main.c_str(), area_rect_main.x, area_rect_main.y, @@ -869,8 +869,8 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char /* * Queueing Phase */ - unsigned current = g_app_list.currentSequenceNumber(); - unsigned requested_num = g_app_list.getSequenceNumber(id); + unsigned current = g_app_list.currentRequestNumber(); + unsigned requested_num = g_app_list.getRequestNumber(id); if (requested_num != 0) { HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str()); @@ -925,8 +925,8 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co /* * Queueing Phase */ - unsigned current = g_app_list.currentSequenceNumber(); - unsigned requested_num = g_app_list.getSequenceNumber(id); + unsigned current = g_app_list.currentRequestNumber(); + unsigned requested_num = g_app_list.getRequestNumber(id); if (requested_num != 0) { HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str()); @@ -999,30 +999,30 @@ void App::lm_enddraw(const char *drawing_name) } } -void App::do_enddraw(unsigned request_seq) +void App::do_enddraw(unsigned req_num) { // get actions - auto actions = g_app_list.getActions(request_seq); - HMI_SEQ_INFO(request_seq, "do endDraw"); + auto actions = g_app_list.getActions(req_num); + HMI_SEQ_INFO(req_num, "do endDraw"); for (const auto &act : actions) { - HMI_SEQ_DEBUG(request_seq, "visible %s", act.role.c_str()); + HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str()); this->lm_enddraw(act.role.c_str()); } - HMI_SEQ_INFO(request_seq, "emit flushDraw"); + HMI_SEQ_INFO(req_num, "emit flushDraw"); /* do { // emit flush Draw - //emitFlushDrawToAll(&g_app_list, request_seq); + //emitFlushDrawToAll(&g_app_list, req_num); // emit status change event } while (!g_app_list.requestFinished());*/ } void App::process_request() { - unsigned req = g_app_list.currentSequenceNumber(); + unsigned req = g_app_list.currentRequestNumber(); HMI_SEQ_DEBUG(req, "Do next request"); do_transition(req); } @@ -1031,8 +1031,8 @@ void App::api_enddraw(char const *appid, char const *drawing_name) { std::string id(appid); std::string role(drawing_name); - unsigned current_seq = g_app_list.currentSequenceNumber(); - bool result = g_app_list.setEndDrawFinished(current_seq, id, role); + unsigned current_req = g_app_list.currentRequestNumber(); + bool result = g_app_list.setEndDrawFinished(current_req, id, role); if (!result) { @@ -1040,16 +1040,16 @@ void App::api_enddraw(char const *appid, char const *drawing_name) return; } - if (g_app_list.endDrawFullfilled(current_seq)) + if (g_app_list.endDrawFullfilled(current_req)) { // do task for endDraw //this->stop_timer(); - this->do_enddraw(current_seq); + this->do_enddraw(current_req); this->stop_timer(); - g_app_list.removeRequest(current_seq); - HMI_SEQ_INFO(current_seq, "Finish request"); + g_app_list.removeRequest(current_req); + HMI_SEQ_INFO(current_req, "Finish request"); g_app_list.next(); if (g_app_list.haveRequest()) { @@ -1058,7 +1058,7 @@ void App::api_enddraw(char const *appid, char const *drawing_name) } else { - HMI_SEQ_INFO(current_seq, "Wait other App call endDraw"); + HMI_SEQ_INFO(current_req, "Wait other App call endDraw"); return; } } diff --git a/src/app.hpp b/src/app.hpp index 25a72cb..2ee3560 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -261,9 +261,9 @@ struct App void emit_invisible(char const *label); void emit_visible(char const *label); - bool do_transition(unsigned sequence_number); + bool do_transition(unsigned req_num); - void do_enddraw(unsigned sequence_number); + void do_enddraw(unsigned req_num); void process_request(); void set_timer(); void stop_timer(); diff --git a/src/applist.cpp b/src/applist.cpp index 66289ea..462a0d8 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -88,20 +88,20 @@ int AppList::countClient() return this->app2client.size(); } -unsigned AppList::currentSequenceNumber() +unsigned AppList::currentRequestNumber() { return this->current_req; } // Is this function necessary ? -unsigned AppList::getSequenceNumber(const string &appid) +unsigned AppList::getRequestNumber(const string &appid) { for (const auto &x : this->req_list) { // Since app will not request twice and more, comparing appid is enough? if ((x.trigger.appid == appid)) { - return x.seq_num; + return x.req_num; } } return 0; @@ -111,15 +111,15 @@ unsigned AppList::addAllocateRequest(WMRequest req) { if (this->req_list.size() == 0) { - req.seq_num = current_req; + req.req_num = current_req; } else { - HMI_SEQ_DEBUG(this->current_req, "add: %d", this->req_list.back().seq_num + 1); - req.seq_num = this->req_list.back().seq_num + 1; + HMI_SEQ_DEBUG(this->current_req, "add: %d", this->req_list.back().req_num + 1); + req.req_num = this->req_list.back().req_num + 1; } this->req_list.push_back(req); - return req.seq_num; // return 1; if you test time_expire + return req.req_num; // return 1; if you test time_expire } bool AppList::requestFinished() @@ -131,7 +131,7 @@ struct WMTrigger AppList::getRequest(unsigned req_num) { for (auto &x : this->req_list) { - if (req_num == x.seq_num) + if (req_num == x.req_num) { return x.trigger; } @@ -142,7 +142,7 @@ const vector &AppList::getActions(unsigned req_num) { for (auto &x : this->req_list) { - if (req_num == x.seq_num) + if (req_num == x.req_num) { return x.sync_draw_req; } @@ -154,7 +154,7 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) bool result = false; for (auto &x : this->req_list) { - if (req_num != x.seq_num) + if (req_num != x.req_num) { continue; } @@ -178,7 +178,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol bool result = false; for (auto &x : req_list) { - if (req_num != x.seq_num) + if (req_num != x.req_num) { continue; } @@ -192,16 +192,21 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol return result; } +/** + * This function checks + * * req_num is equal to current request number + * * appid and role are equeal to the appid and role stored in action list(sync_draw_req) + */ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role) { bool result = false; for (auto &x : req_list) { - if (req_num < x.seq_num) + if (req_num < x.req_num) { break; } - if (req_num == x.seq_num) + if (req_num == x.req_num) { for (auto &y : x.sync_draw_req) { @@ -219,7 +224,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st /** * @brief check all actions of the requested sequence is finished - * @param unsigned sequence_num + * @param unsigned request_number * @return true if all action is set. */ bool AppList::endDrawFullfilled(unsigned req_num) @@ -227,11 +232,11 @@ bool AppList::endDrawFullfilled(unsigned req_num) bool result = false; for (const auto &x : req_list) { - if (req_num < x.seq_num) + if (req_num < x.req_num) { break; } - if (req_num == x.seq_num) + if (req_num == x.req_num) { result = true; for (const auto &y : x.sync_draw_req) @@ -247,11 +252,11 @@ bool AppList::endDrawFullfilled(unsigned req_num) return result; } -void AppList::removeRequest(unsigned req_seq) +void AppList::removeRequest(unsigned req_num) { this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(), - [req_seq](WMRequest x) { - return x.seq_num == req_seq; + [req_num](WMRequest x) { + return x.req_num == req_num; })); } @@ -286,7 +291,7 @@ void AppList::reqDump() DUMP("current request : %d", current_req); for (const auto &x : req_list) { - DUMP("requested with : %d", x.seq_num); + DUMP("requested with : %d", x.req_num); DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)", x.trigger.appid.c_str(), x.trigger.role.c_str(), diff --git a/src/applist.hpp b/src/applist.hpp index 320d36b..a5f64d4 100644 --- a/src/applist.hpp +++ b/src/applist.hpp @@ -47,8 +47,8 @@ class AppList void removeSurface(unsigned surface); // Request Interface - unsigned currentSequenceNumber(); - unsigned getSequenceNumber(const std::string &appid); + unsigned currentRequestNumber(); + unsigned getRequestNumber(const std::string &appid); unsigned addAllocateRequest(WMRequest req); /* TODO: consider, which is better WMClient or std::string appid? if appid is key to manage resources, it is better to select std::string diff --git a/src/request.cpp b/src/request.cpp index 97b9f49..069f8ff 100644 --- a/src/request.cpp +++ b/src/request.cpp @@ -24,7 +24,7 @@ using std::string; WMRequest::WMRequest() {} WMRequest::WMRequest(string appid, string role, string area, Task task) - : seq_num(0), + : req_num(0), trigger{appid, role, area, task}, sync_draw_req(0) { @@ -36,7 +36,7 @@ WMRequest::~WMRequest() WMRequest::WMRequest(const WMRequest &obj) { - this->seq_num = obj.seq_num; + this->req_num = obj.req_num; this->trigger = obj.trigger; this->sync_draw_req = obj.sync_draw_req; } diff --git a/src/request.hpp b/src/request.hpp index 9a97abb..ab1ef95 100644 --- a/src/request.hpp +++ b/src/request.hpp @@ -54,7 +54,7 @@ struct WMRequest virtual ~WMRequest(); WMRequest(const WMRequest &obj); - unsigned seq_num; + unsigned req_num; struct WMTrigger trigger; std::vector sync_draw_req; }; -- cgit 1.2.3-korg From 7f6ceaf920b5cb0d5984b8e8294f8ce0f52dfbbb Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 8 Jun 2018 00:53:53 +0900 Subject: Add const to get functions Change-Id: Ibb6976639018f4f45132577f77d57096e2512997 Signed-off-by: Kazumasa Mitsunari --- src/applist.cpp | 14 +++++++------- src/applist.hpp | 12 ++++++------ src/wm-client.cpp | 9 ++++----- src/wm-client.hpp | 8 ++++---- 4 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src/applist.cpp') diff --git a/src/applist.cpp b/src/applist.cpp index 462a0d8..2575849 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -53,7 +53,7 @@ void AppList::removeClient(const string &appid) this->app2client.erase(appid); } -bool AppList::contains(const string &appid) +bool AppList::contains(const string &appid) const { auto result = this->app2client.find(appid); return (this->app2client.end() != result) ? true : false; @@ -83,18 +83,18 @@ shared_ptr AppList::lookUpClient(const string &appid) return this->app2client.at(appid); } -int AppList::countClient() +int AppList::countClient() const { return this->app2client.size(); } -unsigned AppList::currentRequestNumber() +unsigned AppList::currentRequestNumber() const { return this->current_req; } // Is this function necessary ? -unsigned AppList::getRequestNumber(const string &appid) +unsigned AppList::getRequestNumber(const string &appid) const { for (const auto &x : this->req_list) { @@ -122,14 +122,14 @@ unsigned AppList::addAllocateRequest(WMRequest req) return req.req_num; // return 1; if you test time_expire } -bool AppList::requestFinished() +bool AppList::requestFinished() const { return this->req_list.empty(); } struct WMTrigger AppList::getRequest(unsigned req_num) { - for (auto &x : this->req_list) + for (const auto &x : this->req_list) { if (req_num == x.req_num) { @@ -269,7 +269,7 @@ void AppList::next() } } -bool AppList::haveRequest() +bool AppList::haveRequest() const { return !this->req_list.empty(); } diff --git a/src/applist.hpp b/src/applist.hpp index a5f64d4..bb80961 100644 --- a/src/applist.hpp +++ b/src/applist.hpp @@ -41,26 +41,26 @@ class AppList void addClient(const std::string &appid, const std::string &role); void addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role); void removeClient(const std::string &appid); - bool contains(const std::string &appid); - int countClient(); + bool contains(const std::string &appid) const; + int countClient() const; std::shared_ptr lookUpClient(const std::string &appid); void removeSurface(unsigned surface); // Request Interface - unsigned currentRequestNumber(); - unsigned getRequestNumber(const std::string &appid); + unsigned currentRequestNumber() const; + unsigned getRequestNumber(const std::string &appid) const; unsigned addAllocateRequest(WMRequest req); /* TODO: consider, which is better WMClient or std::string appid? if appid is key to manage resources, it is better to select std::string otherwise WMClient is better, IMO */ - bool requestFinished(); + bool requestFinished() const; bool setAction(unsigned req_num, const struct WMAction &action); bool setAction(unsigned req_num, const std::string &appid, const std::string &role, const std::string &area, bool visible = true); bool setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role); bool endDrawFullfilled(unsigned req_num); void removeRequest(unsigned req_num); void next(); - bool haveRequest(); + bool haveRequest() const; struct WMTrigger getRequest(unsigned req_num); const std::vector &getActions(unsigned req_num); diff --git a/src/wm-client.cpp b/src/wm-client.cpp index 13dae6f..2542016 100644 --- a/src/wm-client.cpp +++ b/src/wm-client.cpp @@ -38,8 +38,7 @@ static const char kKeyError[] = "error"; static const char kKeyErrorDesc[] = "kErrorDescription"; WMClient::WMClient(const string &appid, unsigned layerID, unsigned surfaceID, const string &role) - : layer(layerID), - id(appid), + : id(appid), layer(layerID), role2surface(0) { role2surface[role] = surfaceID; @@ -76,12 +75,12 @@ WMClient::~WMClient() { } -string WMClient::appID() +string WMClient::appID() const { return this->id; } -unsigned WMClient::surfaceID(const string &role) +unsigned WMClient::surfaceID(const string &role) const { if (0 == this->role2surface.count(role)) { @@ -91,7 +90,7 @@ unsigned WMClient::surfaceID(const string &role) return this->role2surface.at(role); } -unsigned WMClient::layerID() +unsigned WMClient::layerID() const { return this->layer; } diff --git a/src/wm-client.hpp b/src/wm-client.hpp index 459822d..ad9e7b0 100644 --- a/src/wm-client.hpp +++ b/src/wm-client.hpp @@ -43,9 +43,9 @@ class WMClient WMClient(const std::string &appid, const std::string &role); virtual ~WMClient(); - std::string appID(); - unsigned surfaceID(const std::string &role); - unsigned layerID(); + std::string appID() const; + unsigned surfaceID(const std::string &role) const; + unsigned layerID() const; void registerLayer(unsigned layerID); bool addSurface(const std::string& role, unsigned surface); bool removeSurfaceIfExist(unsigned surfaceID); @@ -57,8 +57,8 @@ class WMClient void dumpInfo(); private: - unsigned layer; std::string id; + unsigned layer; std::unordered_map role2surface; #if GTEST_ENABLED // This is for unit test. afb_make_event occurs sig11 if call not in afb-binding -- cgit 1.2.3-korg