app2client(),
current_req(1)
{
- app2client.reserve(kReserveClientSize);
- req_list.reserve(kReserveReqSize);
+ this->app2client.reserve(kReserveClientSize);
+ this->req_list.reserve(kReserveReqSize);
}
AppList::~AppList() {}
*/
void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, surface, role);
this->app2client[appid] = client;
this->clientDump();
*/
void AppList::removeClient(const string &appid)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
this->app2client.erase(appid);
HMI_INFO("wm", "Remove client %s", appid.c_str());
}
return (this->app2client.end() != result) ? true : false;
}
-void AppList::removeSurface(unsigned surface_id){
+/**
+ * Remove surface from client
+ *
+ * @param unsigned[in] surface id.
+ * @return None
+ */
+void AppList::removeSurface(unsigned surface){
// This function may be very slow
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
bool ret = false;
for (auto &x : this->app2client)
{
- ret = x.second->removeSurfaceIfExist(surface_id);
+ ret = x.second->removeSurfaceIfExist(surface);
if(ret){
- HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface_id, x.second->appID().c_str());
+ HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface, x.second->appID().c_str());
break;
}
}
*
* Returns the number of client stored in the list.
*
- * @param string[in] application id(key)
- * @return WMClient object
- * @attention Must call cantains to check appid is stored before this function.
+ * @param None
+ * @return The number of client
*/
int AppList::countClient() const
{
return this->app2client.size();
}
+/**
+ * Get AppID with surface and role.
+ *
+ * Returns AppID if found.
+ *
+ * @param unsigned[in] surfaceID
+ * @param string[in] role
+ * @param bool[in,out] (key)
+ * @return WMClient object
+ * @attention If AppID is not found, param found will be false.
+ */
+string AppList::getAppID(unsigned surface, const string& role, bool* found) const
+{
+ *found = false;
+ for (const auto &x : this->app2client)
+ {
+ if(x.second->surfaceID(role) == surface){
+ *found = true;
+ return x.second->appID();
+ }
+ }
+ return string("");
+}
+
// =================== Request Date container API ===================
/**
*/
unsigned AppList::addAllocateRequest(WMRequest req)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
if (this->req_list.size() == 0)
{
req.req_num = current_req;
*/
WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
WMError result = WMError::FAIL;
for (auto &x : this->req_list)
{
*/
WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
WMError result = WMError::FAIL;
for (auto &x : req_list)
{
*/
bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
bool result = false;
for (auto &x : req_list)
{
*/
void AppList::removeRequest(unsigned req_num)
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(),
[req_num](WMRequest x) {
return x.req_num == req_num;
*/
void AppList::next()
{
- std::lock_guard<std::mutex> lock(mtx);
+ std::lock_guard<std::mutex> lock(this->mtx);
++this->current_req;
if (0 == this->current_req)
{