Details of namespace alib::enums.
Type Index: | |
struct | EnumRecordHook |
struct | EnumRecordKey |
Function Index: | |
ALIB_API const 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) |
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 .
rtti | The enumeration type. |
integral | The integral value of the enum element. |
nullptr
if not found. Definition at line 60 of file records.cpp.
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.
std::unordered_map
.Definition at line 77 of file records.cpp.
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.
rtti | The enumeration type. |
integral | The integral value of the enum element. |
record | The record to associate. |
Definition at line 51 of file records.cpp.