ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
dbgsingletons.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_singletons of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_ALIB_SINGLETONS_DBGSINGLETONS
9#define HPP_ALIB_SINGLETONS_DBGSINGLETONS 1
10
11#if !defined(HPP_ALIB_SINGLETONS_SINGLETON)
13#endif
14
15#if ALIB_FEAT_SINGLETON_MAPPED && ALIB_DEBUG
16
17#if !defined(HPP_ALIB_COMPATIBILITY_STD_TYPEINFO)
19#endif
20
21#if ALIB_MONOMEM
22# if !defined(HPP_ALIB_MONOMEM_HASHMAP)
24# endif
25# if !defined(HPP_ALIB_MONOMEM_HASHSET)
27# endif
28#else
29# if !defined(_GLIBCXX_UNORDERED_MAP) && !defined(_UNORDERED_MAP_)
30# include <unordered_map>
31# endif
32# if !defined (_GLIBCXX_MUTEX) && !defined(_MUTEX_)
33# include <mutex>
34# endif
35# if !defined (_GLIBCXX_CSTRING) && !defined(_CSTRING_)
36# include <cstring>
37# endif
38#endif
40
41#if ALIB_MONOMEM
42 /** ********************************************************************************************
43 * This debug helper function returns a type map with void pointers to all singletons.
44 *
45 * The function may be used to investigate which singleton objects are created within a
46 * process and the point in (run-) time of creation.
47 *
48 * \note
49 * This method is available only with debug builds of %ALib and if
50 * code selection symbol \ref ALIB_FEAT_SINGLETON_MAPPED evaluates to true.<br>
51 * The method included with \alibheader{singletons/dbgsingletons.hpp}.
52 *
53 * \note
54 * If the \alibdist includes \alib_strings then a simple dumping method is available with
55 * #DbgGetSingletons(NAString&).
56 *
57 * \attention
58 * If module \alib_monomem is not included in the \alibdist, then the result type of this
59 * method changes to <c>std::unordered_map<TypeKey, void*>&</c>.
60 *
61 *
62 * @return A map of singleton types with void pointers to the singletons.
63 **********************************************************************************************/
67#else
68 ALIB_API std::unordered_map<TypeFunctors::Key, void*,
71#endif
72
73 #if ALIB_STRINGS
74 /** ***************************************************************************************
75 * This debug function writes all type names and addresses of each currently defined
76 * instance of class
77 * \alib{singletons;Singleton}
78 * into the given AString.<br>
79 *
80 * \note
81 * This method is available only
82 * - with \ref ALIB_DEBUG "debug builds" of the software,
83 * - if module \ref alib::strings "ALib Strings" is included in the \alibdist, and
84 * - if code selection symbol \ref ALIB_FEAT_SINGLETON_MAPPED is \c true.
85 *
86 * The method included with \alibheader{singletons/dbgsingletons.hpp}.
87 *
88 * \note
89 * In case module <b>%ALib Strings</b> is not available, then alternative method
90 * \alib{singletons;DbgGetSingletons} can be used. This returns a list of
91 * \c std::type_info structs together with (void-) pointers to the singletons.
92 *
93 * @param target The target string to write the list of singletons to.
94 *
95 * @return The number of singletons written.
96 ******************************************************************************************/
97 ALIB_API int DbgGetSingletons( NAString& target );
98 #endif // ALIB_STRINGS
99
100} // namespace [alib::singletons]
101
102
103#endif // ALIB_FEAT_SINGLETON_MAPPED && ALIB_DEBUG
104#endif // HPP_ALIB_SINGLETONS_DBGSINGLETONS
#define ALIB_API
Definition alib.hpp:538
ALIB_API HashMap< TypeFunctors::Key, void *, TypeFunctors::Hash, TypeFunctors::EqualTo > & DbgGetSingletons()