ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxing_debug.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_boxing of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#if ALIB_DEBUG_BOXING
9
10ALIB_EXPORT namespace alib::boxing {
11
12//==================================================================================================
13/// This namespace provides low- and high-level debug function for \alib_boxing_nl.<br>
14///
15/// To shorten custom type names, custom namespaces might be added to vector
16/// \alib{boxing;debug::RemovableNamespaces} before invoking a function.
17///
18/// \note
19/// Some of the functions are named with a non-capital letter which in \alib-types usually
20// indicates that they are \c protected or \c private.
21// These functions are "inner" functions used by the similar named capitalized functions.
22/// Their use is recommended, when writing custom "composite" debug-functions, as the various
23/// output parameters might be reused with subsequent invocations.
24///
25/// \par Availability
26/// This namespace is only available if the compiler-symbol \ref ALIB_DEBUG_BOXING is set.
27///
28/// \par
29/// The following functions are available independent of the \alibbuild.
30/// - #GetKnownVTables
31/// - #GetKnownFunctionTypes
32/// - #GetSpecificFunctionTypes
33/// - #getFunctionTypes
34/// \par
35/// The following functions become available if module \alib_strings is included in the \alibbuild:
36/// - #TypeName
37/// - #typeName
38/// - #removeNamespaces
39///
40/// \par
41/// All other functions become available if the module \alib_format is included in the \alibbuild.
42/// If in addition symbol \ref ALIB_DEBUG_CONTAINERS is given, then a final function becomes
43/// available:
44/// - #DumpCustomFunctionHashMapMetrics
45
46/// \see
47/// Chapter \ref alib_boxing_more_debug of the
48/// \ref alib_mod_boxing "Programmer's Manual" of module \alib_boxing_nl.
49//==================================================================================================
50namespace debug {
51
52/// Registers a virtual table for debug purposes.
53/// This function is invoked internally, when a dynamic \e vtable is created and
54/// when a static \e vtable is registered.
55///
56/// Statically created \e vtables have to be registered during bootstrap in debug-compilations.
57/// For this, macro \ref ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER is available, which is empty
58/// in release compilations.
59///
60/// \see
61/// Macros ALIB_BOXING_VTABLE_DECLARE and \ref alib_mod_boxing "Programmer's Manual" chapter
62/// \ref alib_boxing_more_opt_staticvt.
63///
64/// @param vtable The vtable to register.
65/// @param productionType Denotes whether the \p{vtable} is a static constexpr object or
66/// dynamically created from template type \b VTableUnoptimized.
68void DbgRegisterVTable( detail::VTable* vtable, detail::VTable::DbgFactoryType productionType );
69
70/// Returns all \e vtable singletons that have been created during program execution so far.
71/// One \e vtable is created for each mapped type used.
72///
73/// \see
74/// The result can be conveniently passed to #DumpVTables.
75/// @return A vector of pointers to objects of type \alib{boxing;detail::VTable}.
77std::vector<detail::VTable*>
79
80/// Returns a vector of \c std::type_info objects, representing all function types that either
81/// a default or a type specific implementation has been registered for.<br>
82/// A second value in the vector provides the number of invocations of a default implementation.
83/// If such is not available, this number is set to <c>std::numeric_limits<uinteger>::max()</c>.
84///
85/// The list includes the built-in function types.
86///
87/// \see
88/// The result can be conveniently passed to #DumpFunctions.
89/// @return A vector of pairs of type information structs and usage numbers.
91std::vector<std::pair<const std::type_info*,uinteger>>
93
94/// Collects all function declarator types of the given box-function table.
95///
96/// \see
97/// The result can be conveniently passed to #DumpFunctions.
98///
99/// @param input The function table to use.
100/// @param output The result vector to fill.
102void getFunctionTypes( const detail::FunctionTable& input,
103 std::vector<std::pair<const std::type_info*,uinteger>>& output );
104
105/// Collects all function declarator types, with type-specific implementations.
106/// Parameter \p{vtable} might for example be retrieved from a box instance with
107/// \alib{boxing;Box::DbgGetVTable}.
108///
109/// \see
110/// The result can be conveniently passed to #DumpFunctions.
111/// @param vtable The vtable to get all function implementations for.
112/// @return A vector of type information structs.
113inline
114std::vector<std::pair<const std::type_info*,uinteger>>
116{
117 std::vector<std::pair<const std::type_info*,uinteger>> result;
118 getFunctionTypes( vtable->Functions, result );
119 return result;
120}
121
122/// Convenience function: invokes #GetSpecificFunctionTypes(const detail::VTable*) with
123/// the \e vtable of the box created or passed with the invocation.
124///
125/// \see
126/// The result can be conveniently passed to #DumpFunctions.
127///
128/// @param box A box that the vtable is used of.
129/// @return A vector of type information structs.
130inline
131std::vector<std::pair<const std::type_info*,uinteger>>
134
135#if ALIB_STRINGS
136/// Implementation of #TypeName.
137///
138/// \par Availability
139/// This function is included only if module \alib_strings is included in the \alibbuild.
140///
141/// @param vtable The vtable.
142/// @param[out] result The target string to write the type information to.
143ALIB_DLL void typeName( const detail::VTable* vtable, AString& result );
144
145/// Writes the (demangled) mapped type that the given \p{vtable} represents.
146///
147/// \par Availability
148/// This function is included only if module \alib_strings is included in the \alibbuild.
149///
150/// @param vtable The \e vtable to get the mapped type name for.
151/// @return A string containing the requested information.
152inline AString TypeName ( const detail::VTable* vtable )
153{
154 AString result;
155 typeName( vtable, result );
156 return result;
157}
158
159/// Convenience function: invokes #TypeName(const detail::VTable*) with
160/// the \e vtable of the box created or passed with the invocation.
161///
162/// \par Availability
163/// This function is included only if module \alib_strings is included in the \alibbuild.
164///
165/// @param box The box to get the mapped type name for.
166/// @return A string containing the requested information.
167inline AString TypeName( const Box& box )
168{
169 AString result;
170 typeName( box.DbgGetVTable(), result );
171 return result;
172}
173
174/// Removes namespaces in the given \p{string}. The function is used with all debug-functions that
175/// create string values containing type names.
176/// Note that custom namespaces might be added to namespace variable
177/// \alib{boxing;debug::RemovableNamespaces} before invoking any function.
178///
179/// @param string The string to remove the namespace from.
180/// @param startIndex The index within the string to start searching for removable namespaces.
181/// @return A string containing the requested information.
182ALIB_DLL AString& removeNamespaces( AString& string, integer startIndex );
183
184/// See function #removeNamespaces. Pre-initialized with <b>"alib::"</b>.
185ALIB_DLL extern std::vector<String> RemovableNamespaces;
186
187#endif // ALIB_STRINGS
188
189}} // namespace [alib::boxing::debug]
190
191#endif // ALIB_DEBUG_BOXING
192
const detail::VTable * DbgGetVTable() const
Definition box.inl:386
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_EXPORT
Definition alib.inl:488
std::vector< alib::String > RemovableNamespaces
See function removeNamespaces. Pre-initialized with "alib::".
ALIB_DLL std::vector< std::pair< const std::type_info *, uinteger > > GetKnownFunctionTypes()
Definition vtable.cpp:185
ALIB_DLL std::vector< detail::VTable * > GetKnownVTables()
Definition vtable.cpp:159
AString & removeNamespaces(AString &string, integer startIndex)
void typeName(const detail::VTable *vtable, AString &result)
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
ALIB_DLL void getFunctionTypes(const detail::FunctionTable &input, std::vector< std::pair< const std::type_info *, uinteger > > &output)
Definition vtable.cpp:219
std::vector< std::pair< const std::type_info *, uinteger > > GetSpecificFunctionTypes(const detail::VTable *vtable)
AString TypeName(const detail::VTable *vtable)
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
The custom function hash.
Definition vtable.inl:227
FunctionTable Functions
Box-functions attached with BootstrapRegister.
Definition vtable.inl:259