ALib C++ Framework
by
Library Version: 2511 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 #"mainpage_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/// #"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 configuration macro #"ALIB_DEBUG_BOXING" is set.
27///
28/// \par
29/// The following functions are available independent of the \alibbuild.
30/// - #"GetKnownVTables"
31/// - #"GetKnownFunctionTypes"
32/// - #"GetSpecificFunctionTypes(const Box&)"
33/// - #"GetSpecificFunctionTypes(const detail::VTable*)"
34/// - #"getFunctionTypes"
35/// \par
36/// The following functions become available if module \alib_strings is included in the \alibbuild:
37/// - #"TypeName(const Box&)",
38/// - #"TypeName(const detail::VTable*)", and
39/// - #"RemoveNamespaces".
40///
41/// \par
42/// All other functions become available if the module \alib_format is included in the \alibbuild.
43/// If in addition configuration macro #"ALIB_DEBUG_CONTAINERS" is given, then a final function becomes
44/// available:
45/// - #"DumpCustomFunctionHashMapMetrics"
46
47/// \see
48/// Chapter #"alib_boxing_more_debug" of the
49/// #"alib_mod_boxing;Programmer's Manual" of module \alib_boxing_nl.
50//==================================================================================================
51namespace debug {
52
53/// Registers a virtual table for debug purposes.
54/// This function is invoked internally, when a dynamic \e vtable is created and
55/// when a static \e vtable is registered.
56///
57/// Statically created \e vtables have to be registered during bootstrap in debug-compilations.
58/// For this, macro #"ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER" is available, which is empty
59/// in release compilations.
60///
61/// \see
62/// Macros ALIB_BOXING_VTABLE_DECLARE and #"alib_mod_boxing;Programmer's Manual" chapter
63/// #"alib_boxing_more_opt_staticvt".
64///
65/// @param vtable The vtable to register.
66/// @param productionType Denotes whether the \p{vtable} is a static constexpr object or
67/// dynamically created from template type \b VTableUnoptimized.
69void DbgRegisterVTable( detail::VTable* vtable, detail::VTable::DbgFactoryType productionType );
70
71/// Returns all \e vtable singletons that have been created during program execution so far.
72/// One \e vtable is created for each mapped type used.
73///
74/// \see
75/// The result can be conveniently passed to #"DumpVTables".
76/// @return A vector of pointers to objects of type #"detail::VTable".
78std::vector<detail::VTable*>
80
81/// Returns a vector of \c std::type_info objects, representing all function types that either
82/// a default or a type specific implementation has been registered for.<br>
83/// A second value in the vector provides the number of invocations of a default implementation.
84/// If such is not available, this number is set to <c>std::numeric_limits<uinteger>::max()</c>.
85///
86/// The list includes the built-in function types.
87///
88/// \see
89/// The result can be conveniently passed to #"DumpFunctions".
90/// @return A vector of pairs of type information structs and usage numbers.
92std::vector<std::pair<const std::type_info*,uinteger>>
94
95/// Collects all function declarator types of the given box-function table.
96///
97/// \see
98/// The result can be conveniently passed to #"DumpFunctions".
99///
100/// @param input The function table to use.
101/// @param output The result vector to fill.
103void getFunctionTypes( const detail::FunctionTable& input,
104 std::vector<std::pair<const std::type_info*,uinteger>>& output );
105
106/// Collects all function declarator types, with type-specific implementations.
107/// Parameter \p{vtable} might, for example, be retrieved from a box instance with
108/// #"Box::DbgGetVTable".
109///
110/// Note that the result can be conveniently passed to #DumpFunctions.
111/// \see Overloaded version #"GetSpecificFunctionTypes(const Box&)" which accepts a "sample Box".
112///
113///
114/// @param vtable The vtable to get all function implementations for.
115/// @return A vector of type information structs.
116inline
117std::vector<std::pair<const std::type_info*,uinteger>>
119{
120 std::vector<std::pair<const std::type_info*,uinteger>> result;
121 getFunctionTypes( vtable->Functions, result );
122 return result;
123}
124
125/// Convenience function: invokes #GetSpecificFunctionTypes(const detail::VTable*) with
126/// the \e vtable of the box created or passed with the invocation.
127///
128/// \see
129/// The result can be conveniently passed to #DumpFunctions.
130///
131/// @param box A box that the vtable is used of.
132/// @return A vector of type information structs.
133inline
134std::vector<std::pair<const std::type_info*,uinteger>>
137
138#if ALIB_STRINGS
139/// Implementation of #TypeName.
140///
141/// \par Availability
142/// This function is included only if module \alib_strings is included in the \alibbuild.
143///
144/// @param vtable The vtable.
145/// @param[out] result The target string to write the type information to.
146ALIB_DLL void typeName( const detail::VTable* vtable, AString& result );
147
148/// Writes the (demangled) mapped type that the given \p{vtable} represents.
149///
150/// \par Availability
151/// This function is included only if module \alib_strings is included in the \alibbuild.
152///
153/// @param vtable The \e vtable to get the mapped type name for.
154/// @return A string containing the requested information.
155inline AString TypeName ( const detail::VTable* vtable )
156{
157 AString result;
158 typeName( vtable, result );
159 return result;
160}
161
162/// Convenience function: invokes #TypeName(const detail::VTable*) with
163/// the \e vtable of the box created or passed with the invocation.
164///
165/// \par Availability
166/// This function is included only if module \alib_strings is included in the \alibbuild.
167///
168/// @param box The box to get the mapped type name for.
169/// @return A string containing the requested information.
170inline AString TypeName( const Box& box )
171{
172 AString result;
173 typeName( box.DbgGetVTable(), result );
174 return result;
175}
176
177/// Removes namespaces in the given \p{string}. The function is used with all debug-functions that
178/// create string values containing type names.
179/// Note that custom namespaces might be added to namespace variable
180/// #"debug::RemovableNamespaces" before invoking any function.
181///
182/// @param string The string to remove the namespace from.
183/// @param startIndex The index within the string to start searching for removable namespaces.
184/// @return A string containing the requested information.
185ALIB_DLL AString& RemoveNamespaces( AString& string, integer startIndex );
186
187/// See function #RemoveNamespaces. Pre-initialized with <b>"alib::"</b>.
188ALIB_DLL extern std::vector<String> RemovableNamespaces;
189
190#endif // ALIB_STRINGS
191
192}} // namespace [alib::boxing::debug]
193
194#endif // ALIB_DEBUG_BOXING
#define ALIB_DLL
Definition alib.inl:573
#define ALIB_EXPORT
Definition alib.inl:562
const detail::VTable * DbgGetVTable() const
Definition box.inl:386
std::vector< std::pair< const std::type_info *, uinteger > > GetKnownFunctionTypes()
Definition vtable.cpp:180
std::vector< alib::String > RemovableNamespaces
See function RemoveNamespaces. Pre-initialized with "alib::".
std::vector< detail::VTable * > GetKnownVTables()
Definition vtable.cpp:154
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
AString & RemoveNamespaces(AString &string, integer startIndex)
void getFunctionTypes(const detail::FunctionTable &input, std::vector< std::pair< const std::type_info *, uinteger > > &output)
Definition vtable.cpp:214
std::vector< std::pair< const std::type_info *, uinteger > > GetSpecificFunctionTypes(const detail::VTable *vtable)
AString TypeName(const detail::VTable *vtable)
void typeName(const detail::VTable *vtable, AString &result)
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
The custom function hash.
Definition vtable.inl:228
FunctionTable Functions
Box-functions attached with #"BootstrapRegister".
Definition vtable.inl:260