summaryrefslogtreecommitdiffstats
path: root/src/layers.cpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:20 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:20 +0200
commit2089b5b1ba2f04f037be1ef897bf79790bf501e2 (patch)
treec8501c5cf0c9cb28741e39ee518477360175a6cb /src/layers.cpp
parentcc06687c8043b93b08202c6c90e588d9b1897c31 (diff)
WIP split layouts, reading config, defining data layout.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/layers.cpp')
-rw-r--r--src/layers.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/layers.cpp b/src/layers.cpp
index c814c22..b931870 100644
--- a/src/layers.cpp
+++ b/src/layers.cpp
@@ -42,6 +42,29 @@ layer::layer(nlohmann::json const &j) {
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), [](json const &sl) {
+ struct split_layout l {};
+ l.name = sl["name"];
+ l.main_match = sl["main_match"];
+ l.sub_match = sl["sub_match"];
+ l.prio = sl.value<int>("priority", 0);
+ logdebug(
+ "Added split_layout \"%s\" (main: \"%s\") (sub: "
+ "\"%s\") (prio: %d)",
+ l.name.c_str(), l.main_match.c_str(),
+ l.sub_match.c_str(), l.prio);
+ return l;
+ });
+ std::sort(std::begin(this->layouts), std::end(this->layouts),
+ [](struct split_layout const &a, struct split_layout const &b) {
+ return a.prio < b.prio;
+ });
+ }
}
struct result<struct layer_map> to_layer_map(nlohmann::json const &j) {
@@ -179,12 +202,9 @@ json layer::to_json() const {
}
return {
- {"id_min", this->id_min},
- {"id_max", this->id_max},
- {"name", this->name},
- {"role", this->role},
- {"layer_id", this->layer_id},
- {"area", r},
+ {"id_min", this->id_min}, {"id_max", this->id_max},
+ {"name", this->name}, {"role", this->role},
+ {"layer_id", this->layer_id}, {"area", r},
};
}