aboutsummaryrefslogtreecommitdiffstats
path: root/src/applist.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-30 19:06:32 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-30 19:06:32 +0900
commitdfe4aee045113eceaeabd327291f94583e7b13d3 (patch)
tree745826e7154c4d08606456dcef68716e64c70b81 /src/applist.cpp
parent5d91a5ffe0bc614ee79a18818dadf5836ce038d7 (diff)
Format source codes
Change-Id: I28e99487b814b23fe99aa6bc8ec4538af3940acf Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/applist.cpp')
-rw-r--r--src/applist.cpp116
1 files changed, 73 insertions, 43 deletions
diff --git a/src/applist.cpp b/src/applist.cpp
index 37a7717..7c554e9 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -23,28 +23,32 @@ using std::string;
using std::unique_ptr;
using std::vector;
-namespace wm {
-
+namespace wm
+{
AppList::AppList()
: req_list(0),
client_list(0),
current_seq(1)
-{}
+{
+}
-AppList::~AppList(){}
+AppList::~AppList() {}
-void AppList::addClient(const string &appid, const string &role){
+void AppList::addClient(const string &appid, const string &role)
+{
shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, role);
client_list[appid] = client;
client_dump();
}
-void AppList::removeClient(const string &appid){
+void AppList::removeClient(const string &appid)
+{
client_list.erase(appid);
}
-bool AppList::contains(const string &appid){
+bool AppList::contains(const string &appid)
+{
auto result = client_list.find(appid);
return (client_list.end() != result) ? true : false;
}
@@ -55,7 +59,7 @@ bool AppList::contains(const string &appid){
* @param string[in] application id(key)
* @return WMClient object
*/
-shared_ptr <WMClient> AppList::lookUpClient(const string &appid)
+shared_ptr<WMClient> AppList::lookUpClient(const string &appid)
{
return client_list.at(appid);
}
@@ -65,15 +69,18 @@ int AppList::countClient()
return client_list.size();
}
-unsigned AppList::currentSequenceNumber(){
+unsigned AppList::currentSequenceNumber()
+{
return current_seq;
}
// Is this function necessary ?
-unsigned AppList::getSequenceNumber(const string &appid){
- for(const auto& x : req_list){
+unsigned AppList::getSequenceNumber(const string &appid)
+{
+ for (const auto &x : req_list)
+ {
// Since app will not request twice and more, comparing appid is enough?
- if( (x.trigger.appid == appid))
+ if ((x.trigger.appid == appid))
{
return x.seq_num;
}
@@ -81,11 +88,14 @@ unsigned AppList::getSequenceNumber(const string &appid){
return 0;
}
-unsigned AppList::addAllocateRequest(WMRequest req){
- if(req_list.size() == 0){
+unsigned AppList::addAllocateRequest(WMRequest req)
+{
+ if (req_list.size() == 0)
+ {
req.seq_num = current_seq;
}
- else{
+ else
+ {
HMI_SEQ_DEBUG(current_seq, "real: %d", req_list.back().seq_num + 1);
req.seq_num = req_list.back().seq_num + 1;
}
@@ -93,12 +103,15 @@ unsigned AppList::addAllocateRequest(WMRequest req){
return req.seq_num; // return 1; if you test time_expire
}
-bool AppList::requestFinished(){
+bool AppList::requestFinished()
+{
return req_list.empty();
}
-struct WMTrigger AppList::getRequest(unsigned req_num){
- for(auto& x : req_list){
+struct WMTrigger AppList::getRequest(unsigned req_num)
+{
+ for (auto &x : req_list)
+ {
if (req_num == x.seq_num)
{
return x.trigger;
@@ -106,7 +119,8 @@ struct WMTrigger AppList::getRequest(unsigned req_num){
}
}
-const vector<struct WMAction>& AppList::getActions(unsigned req_num){
+const vector<struct WMAction> &AppList::getActions(unsigned req_num)
+{
for (auto &x : req_list)
{
if (req_num == x.seq_num)
@@ -116,7 +130,8 @@ const vector<struct WMAction>& AppList::getActions(unsigned req_num){
}
}
-bool AppList::setAction(unsigned req_num, const struct WMAction &action){
+bool AppList::setAction(unsigned req_num, const struct WMAction &action)
+{
bool result = false;
for (auto &x : req_list)
{
@@ -132,9 +147,10 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action){
return result;
}
-bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible){
+bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
+{
bool result = false;
- for (auto& x : req_list)
+ for (auto &x : req_list)
{
if (req_num != x.seq_num)
{
@@ -149,9 +165,10 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol
return result;
}
-bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role){
+bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role)
+{
bool result = false;
- for (auto& x : req_list)
+ for (auto &x : req_list)
{
if (req_num < x.seq_num)
{
@@ -159,7 +176,8 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st
}
if (req_num == x.seq_num)
{
- for(auto& y : x.sync_draw_req){
+ for (auto &y : x.sync_draw_req)
+ {
if (y.appid == appid && y.role == role)
{
y.end_draw_finished = true;
@@ -177,18 +195,23 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st
* @param unsigned sequence_num
* @return true if all action is set.
*/
-bool AppList::endDrawFullfilled(unsigned req_num){
+bool AppList::endDrawFullfilled(unsigned req_num)
+{
bool result = false;
- for (const auto& x : req_list)
+ for (const auto &x : req_list)
{
- if(req_num < x.seq_num){
+ if (req_num < x.seq_num)
+ {
break;
}
- if(req_num == x.seq_num){
+ if (req_num == x.seq_num)
+ {
result = true;
- for(const auto& y : x.sync_draw_req){
+ for (const auto &y : x.sync_draw_req)
+ {
result &= y.end_draw_finished;
- if(!result){
+ if (!result)
+ {
break;
}
}
@@ -197,14 +220,16 @@ bool AppList::endDrawFullfilled(unsigned req_num){
return result;
}
-void AppList::removeRequest(unsigned req_seq){
+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;
- }));
+ [req_seq](WMRequest x) {
+ return x.seq_num == req_seq;
+ }));
}
-void AppList::next(){
+void AppList::next()
+{
++this->current_seq;
if (0 == this->current_seq)
{
@@ -212,14 +237,17 @@ void AppList::next(){
}
}
-bool AppList::haveRequest(){
+bool AppList::haveRequest()
+{
return !req_list.empty();
}
-void AppList::client_dump(){
+void AppList::client_dump()
+{
DUMP("======= client dump =====");
- for(const auto& x : client_list){
- const auto& y = x.second;
+ for (const auto &x : client_list)
+ {
+ const auto &y = x.second;
DUMP("APPID : %s", y->appID().c_str());
}
DUMP("======= client dump end=====");
@@ -229,7 +257,8 @@ void AppList::req_dump()
{
DUMP("======= req dump =====");
DUMP("current request : %d", current_seq);
- for(const auto& x : req_list){
+ for (const auto &x : req_list)
+ {
DUMP("requested with : %d", x.seq_num);
DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)",
x.trigger.appid.c_str(),
@@ -237,7 +266,8 @@ void AppList::req_dump()
x.trigger.area.c_str(),
x.trigger.task);
- for (const auto& y : x.sync_draw_req){
+ for (const auto &y : x.sync_draw_req)
+ {
DUMP(
"Action : (APPID :%s, ROLE :%s, AREA :%s, END_DRAW_FINISHED: %d)",
y.appid.c_str(),
@@ -248,4 +278,4 @@ void AppList::req_dump()
}
DUMP("======= req dump end =====\n");
}
-} \ No newline at end of file
+} // namespace wm \ No newline at end of file