-surface_id_to_layer::surface_id_to_layer(nlohmann::json const &j) {
- // DB(j);
- if (j["type"] == "range") {
- this->id_min = get<int>(j["first_surface_id"]);
- this->id_max = get<int>(j["last_surface_id"]);
- } else {
- this->id_min = this->id_max = get<int>(j["surface_id"]);
+using json = nlohmann::json;
+
+layer::layer(nlohmann::json const &j) {
+ this->role = j["role"];
+ this->name = j["name"];
+ this->layer_id = j["layer_id"];
+ this->rect = genivi::full_rect;
+ if (j["area"]["type"] == "rect") {
+ auto jr = j["area"]["rect"];
+ this->rect = genivi::rect{
+ jr["width"], jr["height"], jr["x"], jr["y"],
+ };
+ }
+ auto split_layouts = j.find("split_layouts");
+ if (split_layouts != j.end()) {
+ auto &sls = j["split_layouts"];
+ // this->layouts.reserve(sls.size());
+ std::transform(std::cbegin(sls), std::cend(sls),
+ std::back_inserter(this->layouts), [this](json const &sl) {
+ struct split_layout l {
+ sl["name"], sl["main_match"], sl["sub_match"] };
+ logdebug(
+ "layer %d add split_layout \"%s\" (main: \"%s\") (sub: "
+ "\"%s\")", this->layer_id,
+ l.name.c_str(), l.main_match.c_str(),
+ l.sub_match.c_str());
+ return l;
+ });