#ifndef TMCAGLWM_APP_HPP
#define TMCAGLWM_APP_HPP
-#include <json.hpp>
-#include <experimental/optional>
+#include <json-c/json.h>
+#include <memory>
-namespace wm {
+#include "afb_binding_api.hpp"
+#include "controller_hooks.hpp"
+#include "layers.hpp"
+#include "layout.hpp"
+#include "result.hpp"
+#include "wayland.hpp"
+#include "config.hpp"
+
+namespace wl {
+struct display;
+}
- using std::experimental::optional;
- using std::experimental::nullopt;
+namespace genivi {
+struct controller;
+}
- template <typename E, typename T>
- struct result {
- optional<E> e;
- optional<T> t;
+namespace wm {
- bool is_ok() const { return this->t != nullopt; }
- bool is_err() const { return this->e != nullopt; }
- T unwrap() { return this->t.value(); }
- };
+struct App {
+ struct binding_api api;
+ struct controller_hooks chooks;
- template <typename E, typename T>
- struct result<E, T> Err(E e) { return result<E, T>{e, nullopt}; }
+ // This is the one thing, we do not own.
+ struct wl::display *display;
- template <typename E, typename T>
- struct result<E, T> Ok(T t) { return result<E, T>{nullopt, t}; }
+ std::unique_ptr<struct genivi::controller> controller;
+ std::vector<std::unique_ptr<struct wl::output>> outputs;
- using json = nlohmann::json;
+ struct config config;
- struct App {
- struct API {
- struct App *app;
+ layouts_type layouts;
+ layer_map layers;
- result<char const *, json> debug_status() const;
- result<char const *, json> debug_layers() const;
- result<char const *, json> debug_surfaces() const;
+ App(wl::display *d);
+ ~App();
- result<char const *, json> register_surface(uint32_t appid, uint32_t surfid);
- };
+ App(App const &) = delete;
+ App &operator=(App const &) = delete;
- struct API api;
+ int init();
+ int dispatch_events();
+ int init_layout();
- App();
- };
+ void surface_created(uint32_t surface_id);
+ void surface_removed(uint32_t surface_id);
+};
-} // namespace wm
+} // namespace wm
-#endif //TMCAGLWM_APP_HPP
+#endif // TMCAGLWM_APP_HPP