notcurses/include/ncpp/Tablet.hh
Nick Black e6637e81cc
Prep for serious rusting #101 (#354)
* CMake: add USE_PANDOC, USE_DOXYGEN options #101
* README: mention rust
* start integrating rust into build #101
* CMake: add USE_NETWORK option for cargo
* Debian: build-dep on doxygen
* rust: colloquy checks in Cargo.lock
* extract NCKEY defines into their own include
* colloquy: use clap to parse CLI args
* CMake: unify option namespace
* Python: update include path
* Rust: fix up --frozen workings for -DUSE_NETWORK=off
* CMake: abstract out colloquy a little
* Sync direct.hh to the New Way
2020-02-18 12:36:16 -05:00

62 lines
1.0 KiB
C++

#ifndef __NCPP_TABLET_HH
#define __NCPP_TABLET_HH
#include <map>
#include <mutex>
#include <notcurses/notcurses.h>
#include "Root.hh"
namespace ncpp
{
class Plane;
class NCPP_API_EXPORT NcTablet : public Root
{
protected:
explicit NcTablet (nctablet *t)
: _tablet (t)
{
if (t == nullptr)
throw invalid_argument ("'t' must be a valid pointer");
};
public:
template<typename T>
T* get_userptr () const noexcept
{
return static_cast<T*>(nctablet_userptr (_tablet));
}
operator nctablet* () const noexcept
{
return _tablet;
}
operator nctablet const* () const noexcept
{
return _tablet;
}
Plane* get_plane () const noexcept;
static NcTablet* map_tablet (nctablet *t) noexcept;
protected:
static void unmap_tablet (NcTablet *p) noexcept;
nctablet* get_tablet () const noexcept
{
return _tablet;
}
private:
nctablet *_tablet = nullptr;
static std::map<nctablet*,NcTablet*> *tablet_map;
static std::mutex tablet_map_mutex;
friend class NcReel;
};
}
#endif