Suil.hpp
1 #pragma once
2 
3 #include <ossia/detail/dylib_loader.hpp>
4 
5 #include <cassert>
6 
7 #include <suil-0/suil/suil.h>
8 
9 class libsuil
10 {
11 public:
12  decltype(&::suil_init) init{};
13  decltype(&::suil_host_new) host_new{};
14  decltype(&::suil_host_set_touch_func) host_set_touch_func{};
15  decltype(&::suil_host_free) host_free{};
16  decltype(&::suil_ui_supported) ui_supported{};
17  decltype(&::suil_instance_new) instance_new{};
18  decltype(&::suil_instance_free) instance_free{};
19  decltype(&::suil_instance_get_handle) instance_get_handle{};
20  decltype(&::suil_instance_get_widget) instance_get_widget{};
21  decltype(&::suil_instance_port_event) instance_port_event{};
22  decltype(&::suil_instance_extension_data) instance_extension_data{};
23 
24  static const libsuil& instance()
25  {
26  static const libsuil self;
27  return self;
28  }
29 
30 private:
31  ossia::dylib_loader library;
32 
33  libsuil()
34  : library("libsuil-0.so.0")
35  {
36  init = library.symbol<decltype(&::suil_init)>("suil_init");
37  host_new = library.symbol<decltype(&::suil_host_new)>("suil_host_new");
38  host_set_touch_func = library.symbol<decltype(&::suil_host_set_touch_func)>(
39  "suil_host_set_touch_func");
40  host_free = library.symbol<decltype(&::suil_host_free)>("suil_host_free");
41  ui_supported = library.symbol<decltype(&::suil_ui_supported)>("suil_ui_supported");
42  instance_new = library.symbol<decltype(&::suil_instance_new)>("suil_instance_new");
43  instance_free
44  = library.symbol<decltype(&::suil_instance_free)>("suil_instance_free");
45  instance_get_handle = library.symbol<decltype(&::suil_instance_get_handle)>(
46  "suil_instance_get_handle");
47  instance_get_widget = library.symbol<decltype(&::suil_instance_get_widget)>(
48  "suil_instance_get_widget");
49  instance_port_event = library.symbol<decltype(&::suil_instance_port_event)>(
50  "suil_instance_port_event");
51  instance_extension_data = library.symbol<decltype(&::suil_instance_extension_data)>(
52  "suil_instance_extension_data");
53 
54  assert(init);
55  assert(host_new);
56  assert(host_set_touch_func);
57  assert(host_free);
58  assert(ui_supported);
59  assert(instance_new);
60  assert(instance_free);
61  assert(instance_get_handle);
62  assert(instance_get_widget);
63  assert(instance_port_event);
64  assert(instance_extension_data);
65  }
66 };
Definition: Suil.hpp:10