Omit std::string to string
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 20 Aug 2018 06:03:57 +0000 (15:03 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 20 Aug 2018 06:03:57 +0000 (15:03 +0900)
Change-Id: I2da511300922859383c9eb30222813cdb0a910e1
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/window_manager.cpp

index 6045eaa..4e41d40 100644 (file)
@@ -26,6 +26,9 @@ extern "C"
 #include <systemd/sd-event.h>
 }
 
+using std::string;
+using std::vector;
+
 namespace wm
 {
 
@@ -100,7 +103,7 @@ static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata
     return 0;
 }
 
-static void onStateTransitioned(std::vector<WMAction> actions)
+static void onStateTransitioned(vector<WMAction> actions)
 {
     g_context->startTransitionWrapper(actions);
 }
@@ -124,15 +127,15 @@ WindowManager::WindowManager(wl::display *d)
       pending_events(false)
 {
     char const *path_layers_json = getenv("AFM_APP_INSTALL_DIR");
-    std::string path;
+    string path;
     if (!path_layers_json)
     {
         HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined");
-        path = std::string(path_layers_json);
+        path = string(path_layers_json);
     }
     else
     {
-        path = std::string(path_layers_json) + std::string("/etc/layers.json");
+        path = string(path_layers_json) + string("/etc/layers.json");
     }
 
     try
@@ -245,13 +248,13 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
     //       so convert role old to new
     const char *role = this->convertRoleOldToNew(drawing_name);
 
-    auto lid = this->layers.get_layer_id(std::string(role));
+    auto lid = this->layers.get_layer_id(string(role));
     if (!lid)
     {
         /**
        * register drawing_name as fallback and make it displayed.
        */
-        lid = this->layers.get_layer_id(std::string("fallback"));
+        lid = this->layers.get_layer_id(string("fallback"));
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
         if (!lid)
         {
@@ -275,11 +278,11 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
         }
 
         // add client into the db
-        std::string appid_str(appid);
-        g_app_list.addClient(appid_str, *lid, id, std::string(role));
+        string appid_str(appid);
+        g_app_list.addClient(appid_str, *lid, id, string(role));
 
         // Set role map of (new, old)
-        this->rolenew2old[role] = std::string(drawing_name);
+        this->rolenew2old[role] = string(drawing_name);
 
         return Ok<int>(id);
     }
@@ -297,7 +300,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
     //       so convert role old to new
     const char *role = this->convertRoleOldToNew(drawing_name);
 
-    auto lid = this->layers.get_layer_id(std::string(role));
+    auto lid = this->layers.get_layer_id(string(role));
     unsigned sid = std::stol(ivi_id);
 
     if (!lid)
@@ -305,7 +308,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
         /**
        * register drawing_name as fallback and make it displayed.
        */
-        lid = this->layers.get_layer_id(std::string("fallback"));
+        lid = this->layers.get_layer_id(string("fallback"));
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
         if (!lid)
         {
@@ -331,11 +334,11 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
     this->layout_commit();
 
     // add client into the db
-    std::string appid_str(appid);
-    g_app_list.addClient(appid_str, *lid, sid, std::string(role));
+    string appid_str(appid);
+    g_app_list.addClient(appid_str, *lid, sid, string(role));
 
     // Set role map of (new, old)
-    this->rolenew2old[role] = std::string(drawing_name);
+    this->rolenew2old[role] = string(drawing_name);
 
     return nullptr;
 }
@@ -352,8 +355,8 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
  * This will be removed.
  * */
 bool WindowManager::api_set_role(char const *appid, char const *drawing_name, unsigned pid){
-    std::string id = appid;
-    std::string role = drawing_name;
+    string id = appid;
+    string role = drawing_name;
     unsigned surface = 0;
     WMError wm_err = WMError::UNKNOWN;
     bool ret = false;
@@ -365,7 +368,7 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
         /**
        * register drawing_name as fallback and make it displayed.
        */
-        lid = this->layers.get_layer_id(std::string("fallback"));
+        lid = this->layers.get_layer_id(string("fallback"));
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role.c_str());
         if (!lid)
         {
@@ -440,9 +443,9 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_
     //       so convert role old to new
     const char *c_role = this->convertRoleOldToNew(drawing_name);
 
-    std::string id = appid;
-    std::string role = c_role;
-    std::string area = drawing_area;
+    string id = appid;
+    string role = c_role;
+    string area = drawing_area;
 
     if(!g_app_list.contains(id))
     {
@@ -507,9 +510,9 @@ void WindowManager::api_deactivate_surface(char const *appid, char const *drawin
     /*
     * Check Phase
     */
-    std::string id = appid;
-    std::string role = c_role;
-    std::string area = ""; //drawing_area;
+    string id = appid;
+    string role = c_role;
+    string area = ""; //drawing_area;
     Task task = Task::TASK_RELEASE;
     unsigned req_num = 0;
     WMError ret = WMError::UNKNOWN;
@@ -551,8 +554,8 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
     //       so convert role old to new
     const char *c_role = this->convertRoleOldToNew(drawing_name);
 
-    std::string id = appid;
-    std::string role = c_role;
+    string id = appid;
+    string role = c_role;
     unsigned current_req = g_app_list.currentRequestNumber();
     bool result = g_app_list.setEndDrawFinished(current_req, id, role);
 
@@ -725,7 +728,7 @@ void WindowManager::surface_properties(unsigned surface_id, unsigned pid)
     afb_service_call_sync("afm-main", "runners", nullptr, &response);
 
     // retrieve appid from pid from application manager
-    std::string appid = "";
+    string appid = "";
     if(response == nullptr)
     {
         HMI_ERROR("wm", "No runners");
@@ -755,7 +758,7 @@ void WindowManager::surface_properties(unsigned surface_id, unsigned pid)
     g_app_list.addFloatingSurface(appid, surface_id, pid);*/
 }
 
-void WindowManager::removeClient(const std::string &appid)
+void WindowManager::removeClient(const string &appid)
 {
     HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str());
     g_app_list.removeClient(appid);
@@ -779,7 +782,7 @@ void WindowManager::timerHandler()
     this->processNextRequest();
 }
 
-void WindowManager::startTransitionWrapper(std::vector<WMAction> &actions)
+void WindowManager::startTransitionWrapper(vector<WMAction> &actions)
 {
     WMError ret;
     unsigned req_num = g_app_list.currentRequestNumber();
@@ -804,7 +807,7 @@ void WindowManager::startTransitionWrapper(std::vector<WMAction> &actions)
         {
             bool found;
             auto const &surface_id = this->lookup_id(act.role.c_str());
-            std::string appid = g_app_list.getAppID(*surface_id, act.role, &found);
+            string appid = g_app_list.getAppID(*surface_id, act.role, &found);
             if (!found)
             {
                 if (TaskVisible::INVISIBLE == act.visible)
@@ -880,9 +883,9 @@ bool WindowManager::pop_pending_events()
 
 optional<int> WindowManager::lookup_id(char const *name)
 {
-    return this->id_alloc.lookup(std::string(name));
+    return this->id_alloc.lookup(string(name));
 }
-optional<std::string> WindowManager::lookup_name(int id)
+optional<string> WindowManager::lookup_name(int id)
 {
     return this->id_alloc.lookup(id);
 }
@@ -958,7 +961,7 @@ int WindowManager::init_layers()
     return 0;
 }
 
-void WindowManager::surface_set_layout(int surface_id, const std::string& area)
+void WindowManager::surface_set_layout(int surface_id, const string& area)
 {
     if (!this->controller->surface_exists(surface_id))
     {
@@ -1024,7 +1027,7 @@ void WindowManager::emit_syncdraw(char const *label, char const *area, int x, in
     this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h);
 }
 
-void WindowManager::emit_syncdraw(const std::string &role, const std::string &area)
+void WindowManager::emit_syncdraw(const string &role, const string &area)
 {
     compositor::rect rect = this->layers.getAreaSize(area);
     this->send_event(kListEventName[Event_SyncDraw],
@@ -1147,7 +1150,7 @@ void WindowManager::deactivate(int id)
     }
 }
 
-WMError WindowManager::setRequest(const std::string& appid, const std::string &role, const std::string &area,
+WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
                             Task task, unsigned* req_num)
 {
     if (!g_app_list.contains(appid))
@@ -1200,7 +1203,7 @@ WMError WindowManager::checkPolicy(unsigned req_num)
         ret = WMError::NO_ENTRY;
         return ret;
     }
-    std::string req_area = trigger.area;
+    string req_area = trigger.area;
 
     if (trigger.task == Task::TASK_ALLOCATE)
     {
@@ -1256,7 +1259,7 @@ WMError WindowManager::startTransition(unsigned req_num)
 
             // TODO: application requests by old role,
             //       so convert role new to old for emitting event
-            std::string old_role = this->rolenew2old[action.role];
+            string old_role = this->rolenew2old[action.role];
 
             this->emit_syncdraw(old_role, action.area);
             /* TODO: emit event for app not subscriber
@@ -1337,7 +1340,7 @@ WMError WindowManager::doEndDraw(unsigned req_num)
         {
             // TODO: application requests by old role,
             //       so convert role new to old for emitting event
-            std::string old_role = this->rolenew2old[act_flush.role];
+            string old_role = this->rolenew2old[act_flush.role];
 
             this->emit_flushdraw(old_role.c_str());
         }
@@ -1392,7 +1395,7 @@ WMError WindowManager::visibilityChange(const WMAction &action)
     return WMError::SUCCESS;
 }
 
-WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area)
+WMError WindowManager::setSurfaceSize(unsigned surface, const string &area)
 {
     this->surface_set_layout(surface, area);
 
@@ -1518,14 +1521,14 @@ int WindowManager::loadOldRoleDb()
     char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
     HMI_DEBUG("wm", "afm_app_install_dir:%s", afm_app_install_dir);
 
-    std::string file_name;
+    string file_name;
     if (!afm_app_install_dir)
     {
         HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined");
     }
     else
     {
-        file_name = std::string(afm_app_install_dir) + std::string("/etc/old_roles.db");
+        file_name = string(afm_app_install_dir) + string("/etc/old_roles.db");
     }
 
     // Load old_role.db
@@ -1568,7 +1571,7 @@ int WindowManager::loadOldRoleDb()
             return -1;
         }
 
-        this->roleold2new[old_role] = std::string(new_role);
+        this->roleold2new[old_role] = string(new_role);
     }
 
     // Check