[Local]:1st step for blocking sequence
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 14 May 2018 01:07:58 +0000 (10:07 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 14 May 2018 01:48:31 +0000 (10:48 +0900)
* add new class to allocate window resource
* add new class for list to hold clients information
* change API of request surface

Change-Id: Ic39fa8908163d49b429125639189dd89812f94e9
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/CMakeLists.txt
src/allocate_queue.cpp [new file with mode: 0644]
src/allocate_queue.hpp [new file with mode: 0644]
src/app.cpp
src/app.hpp
src/main.cpp
src/windowmanager-client.cpp [new file with mode: 0644]
src/windowmanager-client.hpp [new file with mode: 0644]

index cc3efc3..248a058 100644 (file)
@@ -43,7 +43,9 @@ add_library(${TARGETS_WM} MODULE
    controller_hooks.hpp
    config.cpp
    config.hpp
-   policy.hpp)
+   policy.hpp
+   windowmanager-client.cpp
+   allocate_queue.cpp)
 
 target_include_directories(${TARGETS_WM}
     PRIVATE
diff --git a/src/allocate_queue.cpp b/src/allocate_queue.cpp
new file mode 100644 (file)
index 0000000..029c516
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "allocate_queue.hpp"
+
+namespace wm {
+
+AllocateRequestList::AllocateRequestList(){}
+AllocateRequestList::~AllocateRequestList(){}
+void AllocateRequestList::addClient(WMClient* client){
+
+}
+}
\ No newline at end of file
diff --git a/src/allocate_queue.hpp b/src/allocate_queue.hpp
new file mode 100644 (file)
index 0000000..2a977b1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ALLOCATE_LIST_HPP
+#define ALLOCATE_LIST_HPP
+#include <vector>
+#include "windowmanager-client.hpp"
+
+namespace wm {
+
+class  AllocateRequestList {
+public:
+    AllocateRequestList();
+    ~AllocateRequestList();
+    AllocateRequestList(const AllocateRequestList &obj) = delete;
+
+    void addClient(WMClient* client);
+
+    /* bool queue(int request_num);
+    bool pushTop(int request_num);
+    bool dequeue();
+    void deleteAllElement();
+    void removeElement(int request_num);
+    bool hasElement(int request_num); */
+
+private:
+    std::vector<WMClient *> requestQueue;
+
+};
+
+}
+#endif // ALLOCATE_LIST_HPP
\ No newline at end of file
index 937da6a..53a645e 100644 (file)
@@ -35,6 +35,8 @@
 #include <regex>
 #include <thread>
 
+#include "windowmanager-client.hpp"
+#include "allocate_queue.hpp"
 
 namespace wm {
 
@@ -58,6 +60,7 @@ const char kKeyHeightPixel[] = "height_pixel";
 const char kKeyWidthMm[]     = "width_mm";
 const char kKeyHeightMm[]    = "height_mm";
 
+static AllocateRequestList allocate_list;
 
 namespace {
 
@@ -705,7 +708,7 @@ void App::emit_invisible(char const *label) {
 
 void App::emit_visible(char const *label) { return emit_visible(label, true); }
 
-result<int> App::api_request_surface(char const *drawing_name) {
+result<int> App::api_request_surface(char const *drawing_name, char const * appid, int flag) {
    auto lid = this->layers.get_layer_id(std::string(drawing_name));
    if (!lid) {
       /**
@@ -731,6 +734,10 @@ result<int> App::api_request_surface(char const *drawing_name) {
          HMI_DEBUG("wm", "Set main_surface id to %u", id);
       }
 
+      // add client into the db
+      WMClient* client = new WMClient(appid, *lid, id, drawing_name); // role is drawing_name for now
+      allocate_list.addClient(client);
+
       return Ok<int>(id);
    }
 
index d1393c0..5cfd78f 100644 (file)
@@ -201,7 +201,7 @@ struct App {
 
    void set_pending_events();
 
-   result<int> api_request_surface(char const *drawing_name);
+   result<int> api_request_surface(char const *drawing_name, char const *appid, int flag);
    char const *api_request_surface(char const *drawing_name, char const *ivi_id);
    void api_activate_surface(char const *drawing_name, char const *drawing_area, const reply_func &reply);
    void api_deactivate_surface(char const *drawing_name, const reply_func &reply);
index 3828afd..bd591a4 100644 (file)
@@ -209,7 +209,7 @@ void windowmanager_requestsurface(afb_req req) noexcept {
        }
    }
 
-   auto ret = g_afb_instance->app.api_request_surface(a_drawing_name);
+   auto ret = g_afb_instance->app.api_request_surface(a_drawing_name, afb_req_get_application_id(req), 0);
 
    if(isFirstReq){
        wmClientCtxt* ctxt = new wmClientCtxt(a_drawing_name);
diff --git a/src/windowmanager-client.cpp b/src/windowmanager-client.cpp
new file mode 100644 (file)
index 0000000..ee6164a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "windowmanager-client.hpp"
+
+namespace wm {
+
+WMClient::WMClient(){
+
+}
+
+WMClient::WMClient(const char* appid, unsigned layerID, unsigned surfaceID, const char* role)
+    : request_number(0)
+{
+
+}
+
+}
\ No newline at end of file
diff --git a/src/windowmanager-client.hpp b/src/windowmanager-client.hpp
new file mode 100644 (file)
index 0000000..6aec0f3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WINDOWMANAGER_CLIENT_HPP
+#define WINDOWMANAGER_CLIENT_HPP
+
+#include <vector>
+#include <string>
+#include <unordered_map>
+
+extern "C" {
+#include <afb/afb-binding.h>
+}
+
+namespace wm {
+
+class WMClient {
+public:
+    WMClient();
+    WMClient(const char* appid, unsigned layerID, unsigned surfaceID, const char* role);
+    virtual ~WMClient();
+    //WMClient::WMClient(const WMClient &obj);
+
+private:
+    unsigned layer;
+    std::vector<unsigned> surfaces;
+    std::string appid;
+    std::vector<std::string> roles;
+    std::unordered_map<std::string, struct afb_event> event_list;
+    unsigned request_number;
+};
+}
+
+#endif
\ No newline at end of file