Symmetri
Loading...
Searching...
No Matches
symmetri::Token Class Reference

Tokens are elements that can reside in places. Tokens can have a color which makes them distinguishable from other tokens. Tokens that have the same color are not distinguishable. Users can create their own token-colors by either using the CREATE_CUSTOM_TOKEN-macro (compile-time) or by calling Token's public constructor which takes a token-name. More...

#include <colors.hpp>

Inheritance diagram for symmetri::Token:
symmetri::Canceled symmetri::Deadlocked symmetri::Failed symmetri::Paused symmetri::Scheduled symmetri::Started symmetri::Success

Public Member Functions

 Token (const char *s)
 Construct a new Token object from a string at run-time. A unique id is generated and if it fails it will exit the application through a failing assert.
 
constexpr bool operator< (const Token &rhs) const
 
constexpr bool operator> (const Token &rhs) const
 
constexpr size_t toIndex () const
 returns the unique index for this color.
 
constexpr const auto & toString () const
 returns the string-representation for this color.
 
constexpr bool operator== (const Token &c) const
 
template<class T >
constexpr bool operator== (const T &) const
 

Static Public Member Functions

static std::vector< std::string_view > getColors ()
 Get a list of all the colors.
 

Protected Member Functions

template<class T >
constexpr Token (T *const)
 Creates a Token with a unique numerical id and a string representation based on the name of the argument-type at compile-time.
 

Detailed Description

Tokens are elements that can reside in places. Tokens can have a color which makes them distinguishable from other tokens. Tokens that have the same color are not distinguishable. Users can create their own token-colors by either using the CREATE_CUSTOM_TOKEN-macro (compile-time) or by calling Token's public constructor which takes a token-name.

Constructor & Destructor Documentation

◆ Token() [1/2]

template<class T >
symmetri::Token::Token ( T * const )
inlineconstexprprotected

Creates a Token with a unique numerical id and a string representation based on the name of the argument-type at compile-time.

Template Parameters
Tthe type representing the token-color

◆ Token() [2/2]

symmetri::Token::Token ( const char * s)
inline

Construct a new Token object from a string at run-time. A unique id is generated and if it fails it will exit the application through a failing assert.

Parameters
sstring-representation of the color

Member Function Documentation

◆ getColors()

static std::vector< std::string_view > symmetri::Token::getColors ( )
inlinestatic

Get a list of all the colors.

Returns
std::vector<std::string_view>

◆ toIndex()

size_t symmetri::Token::toIndex ( ) const
inlineconstexpr

returns the unique index for this color.

Returns
constexpr size_t

◆ toString()

const auto & symmetri::Token::toString ( ) const
inlineconstexpr

returns the string-representation for this color.

Returns
constexpr const auto&

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