main/app: started to move things to app
[staging/windowmanager.git] / src / app.hpp
1 //
2 // Created by mfritzsc on 7/11/17.
3 //
4
5 #ifndef TMCAGLWM_APP_HPP
6 #define TMCAGLWM_APP_HPP
7
8 #include <json.hpp>
9 #include <experimental/optional>
10
11 namespace wm {
12
13     using std::experimental::optional;
14     using std::experimental::nullopt;
15
16     template <typename E, typename T>
17     struct result {
18         optional<E> e;
19         optional<T> t;
20
21         bool is_ok() const { return this->t != nullopt; }
22         bool is_err() const { return this->e != nullopt; }
23         T unwrap() { return this->t.value(); }
24     };
25
26     template <typename E, typename T>
27     struct result<E, T> Err(E e) { return result<E, T>{e, nullopt}; }
28
29     template <typename E, typename T>
30     struct result<E, T> Ok(T t) { return result<E, T>{nullopt, t}; }
31
32     using json = nlohmann::json;
33
34     struct App {
35         struct API {
36             struct App *app;
37
38             result<char const *, json> debug_status() const;
39             result<char const *, json> debug_layers() const;
40             result<char const *, json> debug_surfaces() const;
41
42             result<char const *, json> register_surface(uint32_t appid, uint32_t surfid);
43         };
44
45         struct API api;
46
47         App();
48     };
49
50 } // namespace wm
51
52 #endif //TMCAGLWM_APP_HPP