ttx 0.1.0
Loading...
Searching...
No Matches
ttx::terminal::IdMap< T, Ops > Class Template Reference

A two-way map between a numberic id and a value. More...

#include <ttx/terminal/id_map.h>

Public Types

using Id = u16
 
using Key = typename Ops::Key
 

Public Member Functions

auto lookup_id (Id id) const -> T const &
 
auto lookup_key (Key const &key) const -> di::Optional< Id >
 
auto allocate (T const &value) -> di::Optional< Id > requires(di::concepts::CopyConstructible< T >)
 
auto allocate (T &&value) -> di::Optional< Id >
 
auto use_id (Id id) -> Id
 
void drop_id (Id id)
 

Static Public Attributes

static constexpr auto max_id = di::NumericLimits<Id>::max
 

Detailed Description

template<typename T, typename Ops = detail::DefaultOps<T>>
class ttx::terminal::IdMap< T, Ops >

A two-way map between a numberic id and a value.

Template Parameters
TThe value type
OpsAn operation struct, which can be used to define a custom key.

This class implements the two way mapping behavior which deduplicates graphics renditions and other cell specific state across cells. This implemenation uses manual reference counting, which is non-ideal for C++, but seems necessary for performance.

Member Typedef Documentation

◆ Id

template<typename T, typename Ops = detail::DefaultOps<T>>
using ttx::terminal::IdMap< T, Ops >::Id = u16

◆ Key

template<typename T, typename Ops = detail::DefaultOps<T>>
using ttx::terminal::IdMap< T, Ops >::Key = typename Ops::Key

Member Function Documentation

◆ allocate() [1/2]

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::allocate ( T && value) -> di::Optional<Id>
inline

◆ allocate() [2/2]

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::allocate ( T const & value) -> di::Optional<Id> requires(di::concepts::CopyConstructible<T>)
inline

◆ drop_id()

template<typename T, typename Ops = detail::DefaultOps<T>>
void ttx::terminal::IdMap< T, Ops >::drop_id ( Id id)
inline

◆ lookup_id()

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::lookup_id ( Id id) const -> T const&
inline

◆ lookup_key()

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::lookup_key ( Key const & key) const -> di::Optional<Id>
inline

◆ use_id()

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::use_id ( Id id) -> Id
inline

Member Data Documentation

◆ max_id

template<typename T, typename Ops = detail::DefaultOps<T>>
auto ttx::terminal::IdMap< T, Ops >::max_id = di::NumericLimits<Id>::max
staticconstexpr

The documentation for this class was generated from the following file: