std::string role = this->app2role_[std::string(drawing_name)];
this->role2surfaceid_[role] = id;
+ // Set map of (role, app)
+ // If the new app which has the same role which is had by existing app is requested,
+ // the role is given to the new app.
+ this->role2app_[role] = std::string(drawing_name);
+
return Ok<int>(id);
}
}
void App::deactivate(std::string role) {
- std::string app = this->roleToApp(role);
+ std::string app = this->role2app_[role];
auto const &id = this->lookup_id(app.c_str());
if (!id) {
HMI_ERROR("wm", "Surface does not exist");
size.x, size.y, size.w, size.h);
// Emit syncDraw event
- const char* app = this->roleToApp(role).c_str();
+ const char* app = this->role2app_[role].c_str();
this->emit_syncdraw(app, area,
size.x, size.y, size.w, size.h);
this->enqueue_flushdraw(surface_id);
}
-std::string App::roleToApp(std::string role) {
- HMI_DEBUG("wm", "Call");
-
- for (auto itr = this->app2role_.begin();
- itr != this->app2role_.end(); itr++) {
- if (role == itr->second) {
- return itr->first;
- }
- }
- return std::string("none");
-}
-
extern const char* kDefaultAppDb;
int App::loadAppDb() {
HMI_DEBUG("wm", "Call");
void surface_removed(uint32_t surface_id);
private:
-#if 1 // @@@@@
PolicyManager pm_;
LayoutManager lm_;
std::unordered_map<std::string, int> role2surfaceid_;
std::unordered_map<std::string, std::string> app2role_;
+ std::unordered_map<std::string, std::string> role2app_;
std::unordered_map<int, int> appid2role_;
int allocateSurface();
void setSurfaceSize(const char* role, const char* area);
- std::string roleToApp(std::string role);
int loadAppDb();
#if 0
struct id_allocator app_id_alloc_;
std::unordered_map<std::string, int> appname2appid_;
#endif
-#endif
+
optional<int> lookup_id(char const *name);
optional<std::string> lookup_name(int id);