ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Nested namespaces | Classes | Functions
aworx::lib::enums::detail Namespace Reference

Details of namespace aworx::lib::enums.

Classes

struct  EnumRecordHook
 
struct  EnumRecordKey
 

Functions

const ALIB_API void * getEnumRecord (const std::type_info &rtti, integer integral)
 
const HashMap< EnumRecordKey, const void *, EnumRecordKey::Hash, EnumRecordKey::EqualTo > & getInternalRecordMap ()
 
ALIB_API void setEnumRecord (const std::type_info &rtti, integer integral, const void *record)
 

Function Documentation

◆ getEnumRecord()

const void * getEnumRecord ( const std::type_info &  rtti,
integer  integral 
)

Retrieves the enum record stored for the enum element with integral value integral of enum type rtti.

Parameters
rttiThe enumeration type.
integralThe integral value of the enum element.
Returns
A pointer to the record, nullptr if not found.

Definition at line 71 of file records.cpp.

◆ getInternalRecordMap()

const HashMap< EnumRecordKey, const void *, EnumRecordKey::Hash, EnumRecordKey::EqualTo > & getInternalRecordMap ( )

This detail function returns the central hash table that stores all enum records of all types. A constant reference is returned, which is in alignment with the general contract of this concept that considers enum records as static data which must not be modified after bootstrapping a software.

Consequently, there are no mechanisms to protect parallel access, as after bootstrap exclusively read operations are allowed.

Prior to bootstrapping, the returned map may be const_cast'ed to a mutable reference for the sake of modifying the base- and maximum load factors as well as for reserving a certain element capacity. The default values are already raised to 3.0 and 6.0, as the retrieval of enumeration records is not considered to be done in time-critical code units.

Direct access to this map is not recommended, and useful only in seldom cases.

A good sample for its use, is to provide debug-output of all defined records for a type in the case that a record for a certain enumeration element of that type was not found, and such output is required to be performed in a code unit that has lost (templated) compile-time type information.

Note
Run-time access to single records is provided with function aworx::lib::enums::detail::getEnumRecord(const std::type_info& rtti " integer)" and encapsulated in type Enum of module ALib Boxing.
Attention
In the absence of module ALib Memory in an ALib Distribution, the returned type changes to std::unordered_map.
Returns
A constant reference to the internal hash map storing all enum records.

Definition at line 88 of file records.cpp.

◆ setEnumRecord()

void setEnumRecord ( const std::type_info &  rtti,
integer  integral,
const void *  record 
)

Stores the record for enum element of the given enum type rtti. If a value already exists, it is ignored. This allows to have multiple records, while only the first is found.

Parameters
rttiThe enumeration type.
integralThe integral value of the enum element.
recordThe record to associate.

Definition at line 55 of file records.cpp.