2020-01-07 22:51:34 +00:00
|
|
|
#ifndef __NCPP_TABLET_HH
|
|
|
|
#define __NCPP_TABLET_HH
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <mutex>
|
|
|
|
|
2020-02-18 17:36:16 +00:00
|
|
|
#include <notcurses/notcurses.h>
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
#include "Root.hh"
|
|
|
|
|
|
|
|
namespace ncpp
|
|
|
|
{
|
|
|
|
class Plane;
|
|
|
|
|
2020-02-06 01:04:56 +00:00
|
|
|
class NCPP_API_EXPORT NcTablet : public Root
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
protected:
|
2020-02-06 01:04:56 +00:00
|
|
|
explicit NcTablet (nctablet *t)
|
2020-01-07 22:51:34 +00:00
|
|
|
: _tablet (t)
|
|
|
|
{
|
|
|
|
if (t == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'t' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
template<typename T>
|
|
|
|
T* get_userptr () const noexcept
|
|
|
|
{
|
2020-02-06 01:04:56 +00:00
|
|
|
return static_cast<T*>(nctablet_userptr (_tablet));
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 01:04:56 +00:00
|
|
|
operator nctablet* () const noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return _tablet;
|
|
|
|
}
|
|
|
|
|
2020-02-06 01:04:56 +00:00
|
|
|
operator nctablet const* () const noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return _tablet;
|
|
|
|
}
|
|
|
|
|
|
|
|
Plane* get_plane () const noexcept;
|
2020-02-06 01:04:56 +00:00
|
|
|
static NcTablet* map_tablet (nctablet *t) noexcept;
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
protected:
|
2020-02-06 01:04:56 +00:00
|
|
|
static void unmap_tablet (NcTablet *p) noexcept;
|
2020-01-07 22:51:34 +00:00
|
|
|
|
2020-02-06 01:04:56 +00:00
|
|
|
nctablet* get_tablet () const noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return _tablet;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-02-06 01:04:56 +00:00
|
|
|
nctablet *_tablet = nullptr;
|
|
|
|
static std::map<nctablet*,NcTablet*> *tablet_map;
|
2020-01-07 22:51:34 +00:00
|
|
|
static std::mutex tablet_map_mutex;
|
|
|
|
|
2020-02-05 22:29:42 +00:00
|
|
|
friend class NcReel;
|
2020-01-07 22:51:34 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|