Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
Tablet.hh
Go to the documentation of this file.
1#ifndef __NCPP_TABLET_HH
2#define __NCPP_TABLET_HH
3
4#include <map>
5#include <mutex>
6
8
9#include "Root.hh"
10
11namespace ncpp
12{
13 class Plane;
14 class NotCurses;
15
17 {
18 protected:
19 explicit NcTablet (nctablet *t, NotCurses *ncinst)
20 : Root (ncinst),
21 _tablet (t)
22 {
23 if (t == nullptr)
24 throw invalid_argument ("'t' must be a valid pointer");
25 };
26
27 public:
28 template<typename T>
29 T* get_userptr () const noexcept
30 {
31 return static_cast<T*>(nctablet_userptr (_tablet));
32 }
33
34 operator nctablet* () const noexcept
35 {
36 return _tablet;
37 }
38
39 operator nctablet const* () const noexcept
40 {
41 return _tablet;
42 }
43
44 Plane* get_plane () const noexcept;
45 static NcTablet* map_tablet (nctablet *t, NotCurses *ncinst = nullptr) noexcept;
46
47 protected:
48 static void unmap_tablet (NcTablet *p) noexcept;
49
50 nctablet* get_tablet () const noexcept
51 {
52 return _tablet;
53 }
54
55 private:
56 nctablet *_tablet = nullptr;
57 static std::map<nctablet*,NcTablet*> *tablet_map;
58 static std::mutex tablet_map_mutex;
59
60 friend class NcReel;
61 };
62}
63#endif
#define NCPP_API_EXPORT
Definition _helpers.hh:9
T * get_userptr() const noexcept
Definition Tablet.hh:29
NcTablet(nctablet *t, NotCurses *ncinst)
Definition Tablet.hh:19
Plane * get_plane() const noexcept
void * nctablet_userptr(nctablet *t)
Definition reel.c:893