tec::Multiton

More...

#include <multiton.hpp>

Public Functions

Name
std::map< ID_T, T >::iterator Begin()
std::map< ID_T, T >::iterator End()
std::size_t Size()
std::vector< ID_T > & Keys()
T Get(const ID_T id)
Get the instance for the given ID.
bool Has(const ID_T id)
void Set(const ID_T id, T instance)
Set (or add/create) an instance for the given ID.
void Remove(const ID_T id)
Remove the instance for the given ID.

Protected Attributes

Name
T default_value
std::map< ID_T, T > instances

Detailed Description

template <typename ID_T ,
typename T >
class tec::Multiton;

Public Functions Documentation

function Begin

static inline std::map< ID_T, T >::iterator Begin()

function End

static inline std::map< ID_T, T >::iterator End()

function Size

static inline std::size_t Size()

function Keys

static inline std::vector< ID_T > & Keys()

function Get

static inline T Get(
    const ID_T id
)

Get the instance for the given ID.

Parameters:

  • const ID The ID of the instance to get.

Return: T The ID's instance or the default one.

This doesn't create an instance if the ID doesn't exist. Instead it just returns the default.

function Has

static inline bool Has(
    const ID_T id
)

function Set

static inline void Set(
    const ID_T id,
    T instance
)

Set (or add/create) an instance for the given ID.

Parameters:

  • const ID id The ID of the instance to set.
  • T instance The ID's instance.

Return: void

function Remove

static inline void Remove(
    const ID_T id
)

Remove the instance for the given ID.

Parameters:

  • const ID id The ID of the instance to remove.

Return: void

Protected Attributes Documentation

variable default_value

static T default_value;

variable instances

static std::map< ID_T, T > instances;

Updated on 2022-07-24 at 19:27:35 +0000