aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.hpp
blob: a3108b37ef316a15fe0d6549763bba738c42fb8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by mfritzsc on 7/11/17.
//

#ifndef TMCAGLWM_APP_HPP
#define TMCAGLWM_APP_HPP

#include <json.hpp>
#include <experimental/optional>

namespace wm {

    using std::experimental::optional;
    using std::experimental::nullopt;

    template <typename E, typename T>
    struct result {
        optional<E> e;
        optional<T> t;

        bool is_ok() const { return this->t != nullopt; }
        bool is_err() const { return this->e != nullopt; }
        T unwrap() { return this->t.value(); }
    };

    template <typename E, typename T>
    struct result<E, T> Err(E e) { return result<E, T>{e, nullopt}; }

    template <typename E, typename T>
    struct result<E, T> Ok(T t) { return result<E, T>{nullopt, t}; }

    using json = nlohmann::json;

    struct App {
        struct API {
            struct App *app;

            result<char const *, json> debug_status() const;
            result<char const *, json> debug_layers() const;
            result<char const *, json> debug_surfaces() const;

            result<char const *, json> register_surface(uint32_t appid, uint32_t surfid);
        };

        struct API api;

        App();
    };

} // namespace wm

#endif //TMCAGLWM_APP_HPP