2 // Created by m on 7/27/17.
5 #ifndef TMCAGLWM_LAYERS_H
6 #define TMCAGLWM_LAYERS_H
9 #include <experimental/optional>
18 struct surface_id_to_layer {
21 std::string name = "";
24 explicit surface_id_to_layer(nlohmann::json const &j);
26 bool operator<(struct surface_id_to_layer const &rhs) const {
27 return this->id_max < rhs.id_max;
31 inline bool operator<(struct surface_id_to_layer const &a, int b) {
35 struct surface_id_to_layer_map {
36 typedef std::set<struct surface_id_to_layer> map_type;
40 std::experimental::optional<int> get_layer_for_surface(int surface_id) {
41 auto i = std::lower_bound(std::cbegin(this->mapping),
42 std::cend(this->mapping), surface_id);
44 if (i != this->mapping.end()) {
45 if (i->id_min <= surface_id) {
46 return std::experimental::optional<int>(i->layer_id);
50 return std::experimental::nullopt;
54 struct result<struct surface_id_to_layer_map> to_surface_id_to_layer_map(
55 nlohmann::json const &j);
59 #endif // TMCAGLWM_LAYERS_H