ASPiK SDK
x11platform.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #pragma once
6 
7 #include "../../vstguifwd.h"
8 #include "x11frame.h"
9 #include <atomic>
10 #include <list>
11 #include <map>
12 #include <memory>
13 #include <mutex>
14 #include <poll.h>
15 #include <unistd.h>
16 #include <unordered_map>
17 
18 //------------------------------------------------------------------------
19 namespace VSTGUI {
20 extern void* soHandle; // shared library handle
21 
22 //------------------------------------------------------------------------
23 namespace X11 {
24 
25 class Frame;
26 class Timer;
27 
28 //------------------------------------------------------------------------
29 class Platform
30 {
31 public:
32  ~Platform ();
33 
34  static Platform& getInstance ();
35  static uint64_t getCurrentTimeMs ();
36 
37  std::string getPath ();
38 
39 private:
40  Platform ();
41 
42  std::string path;
43 };
44 
45 //------------------------------------------------------------------------
46 struct RunLoop
47 {
48  static void init (const SharedPointer<IRunLoop>& runLoop)
49  {
50  if (++instance ().useCount == 1)
51  {
52  instance ().runLoop = runLoop;
53  }
54  }
55 
56  static void exit ()
57  {
58  if (--instance ().useCount == 0)
59  {
60  instance ().runLoop = nullptr;
61  }
62  }
63 
64  static const SharedPointer<IRunLoop> get ()
65  {
66  return instance ().runLoop;
67  }
68 
69 private:
70  static RunLoop& instance ()
71  {
72  static RunLoop gInstance;
73  return gInstance;
74  }
76  std::atomic<uint32_t> useCount {0};
77 };
78 
79 //------------------------------------------------------------------------
81 {
82  void run ();
83  void stop ();
84 
85  bool isRunning () const { return running; }
86 private:
87  bool running {false};
88 };
89 
90 //------------------------------------------------------------------------
91 } // X11
92 } // VSTGUI
Definition: vstguibase.h:299
Definition: x11platform.h:29
Definition: x11platform.h:80
Definition: customcontrols.cpp:8
Definition: x11platform.h:46