aboutsummaryrefslogtreecommitdiffstats
path: root/src/wm_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wm_layer.cpp')
-rw-r--r--src/wm_layer.cpp90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
index 773b5c2..f02a5b6 100644
--- a/src/wm_layer.cpp
+++ b/src/wm_layer.cpp
@@ -15,7 +15,8 @@
*/
#include <regex>
-
+#include <ilm/ilm_control.h>
+#include <stdlib.h>
#include "wm_client.hpp"
#include "wm_layer.hpp"
#include "json_helper.hpp"
@@ -58,23 +59,29 @@ const vector<unsigned> LayerState::getIviIdList()
return this->render_order;
}
-LayerSetting::LayerSetting(const string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end)
- : name(name), type(type),
- role_list(), area_list(), id_list(),
- id_begin(begin), id_end(end)
-{}
-
-void LayerSetting::setRoleList(const string& role)
+WMLayer::WMLayer(json_object* j) : before_state(), state()
{
- this->role_list = role;
-}
+ this->name = jh::getStringFromJson(j, "name");
+ this->role_list = jh::getStringFromJson(j, "role");
+ const char* type = jh::getStringFromJson(j, "type");
+ this->id_begin = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_begin"));
+ this->id_end = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_end"));
-void LayerSetting::appendArea(const string& area)
-{
- this->area_list.push_back(area);
+ if (name.size() == 0 || type || this->id_begin == 0 || this->id_end == 0)
+ {
+ HMI_ERROR("Parse Error!!");
+ exit(1);
+ }
+ if(this->id_begin > this->id_end)
+ {
+ HMI_ERROR("INVALID");
+ exit(1);
+ }
+ string str_type = type;
+ this->type = (str_type == "tile") ? MANAGEMENT_TYPE::TILE : MANAGEMENT_TYPE::STACK;
}
-unsigned LayerSetting::getNewLayerID(const string& role)
+unsigned WMLayer::getNewLayerID(const string& role)
{
unsigned ret = 0;
auto re = std::regex(this->role_list);
@@ -118,61 +125,34 @@ unsigned LayerSetting::getNewLayerID(const string& role)
return ret;
}
-void LayerSetting::removeLayerID(unsigned id)
-{
- auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
- [id](unsigned elm) {
- return elm == id;
- });
- this->id_list.erase(fwd_itr, this->id_list.end());
-}
-
-WMLayer::WMLayer()
- : before_state(),
- state(),
- setting{}
+const string& WMLayer::layerName()
{
- // this->setting = std::make_unique<LayerSetting>(name, type, begin, end);
+ return this->name;
}
-WMLayer::WMLayer(json_object* j) : before_state(), state()
+WMError WMLayer::setLayerState(const LayerState& l)
{
- LayerSetting::MANAGEMENT_TYPE t;
- const char* layer_name = jh::getStringFromJson(j, "name");
- const char* roles = jh::getStringFromJson(j, "role");
- const char* type = jh::getStringFromJson(j, "type");
- int begin = jh::getIntFromJson(j, "id_range_begin");
- int end = jh::getIntFromJson(j, "id_range_end");
- string name = layer_name;
-
- if (layer_name || type || begin < 0 || end < 0)
- {
- HMI_ERROR("Parse Error!!");
- }
- if(begin > end)
- {
- HMI_ERROR("INVALID.");
- }
- string str_type = type;
- t = (str_type == "tile") ? LayerSetting::TILE : LayerSetting::STACK;
- this->setting = std::make_unique<LayerSetting>(name, t, begin, end);
- this->setting->setRoleList(roles);
+ this->before_state = l;
+ return WMError::SUCCESS;
}
-unsigned WMLayer::getNewLayerID(const std::string& role)
+void WMLayer::appendArea(const string& area)
{
- return this->setting->getNewLayerID(role);
+ this->area_list.push_back(area);
}
-WMError WMLayer::setLayerState(const LayerState& l)
+void WMLayer::removeLayerID(unsigned id)
{
- this->before_state = l;
- return WMError::SUCCESS;
+ auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
+ [id](unsigned elm) {
+ return elm == id;
+ });
+ this->id_list.erase(fwd_itr, this->id_list.end());
}
bool WMLayer::checkIDBelongTo(unsigned id)
{
- return (id > this->setting->idBegin() && id < this->setting->idEnd());
+ return (id > this->idBegin() && id < this->idEnd());
}
/* WMError WMLayer::commitChange()