ALib C++ Library
Library Version: 2412 R0
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#pragma once
12#if ALIB_FEAT_SINGLETON_MAPPED && ALIB_DEBUG
13
15#if ALIB_MONOMEM && ALIB_CONTAINERS
18#else
19# include <unordered_map>
20# include <mutex>
21# include <cstring>
22#endif
24
25#if ALIB_MONOMEM && ALIB_CONTAINERS
26 //==============================================================================================
27 /// This debug helper function returns a type map with void pointers to all singletons.
28 ///
29 /// The function may be used to investigate which singleton objects are created within a
30 /// process and the point in (run-) time of creation.
31 ///
32 /// \note
33 /// This method is available only with debug-builds of %ALib and if
34 /// code selection symbol \ref ALIB_FEAT_SINGLETON_MAPPED evaluates to true.<br>
35 /// The method included with \alibheader{singletons/dbgsingletons.hpp}.
36 ///
37 /// \note
38 /// If the \alibdist includes \alib_strings then a simple dumping method is available with
39 /// #DbgGetSingletons(NAString&).
40 ///
41 /// \attention
42 /// If modules \alib_monomem and \alib_containers are not included in the \alibdist, then the
43 /// result type of this method changes to <c>std::unordered_map<TypeKey, void*>&</c>.
44 ///
45 /// @return A map of singleton types with void pointers to the singletons.
46 //==============================================================================================
48 TypeFunctors::Key, void*,
52 Recycling::None >& DbgGetSingletons();
53#else
54 ALIB_API std::unordered_map<TypeFunctors::Key, void*,
57#endif
58
59 #if ALIB_STRINGS
60 //=========================================================================================
61 /// This debug function writes all type names and addresses of each currently defined
62 /// instance of class
63 /// \alib{singletons;Singleton}
64 /// into the given AString.<br>
65 ///
66 /// \note
67 /// This method is available only
68 /// - with \ref ALIB_DEBUG "debug-builds" of the software,
69 /// - if module \ref alib::strings "ALib Strings" is included in the \alibdist, and
70 /// - if code selection symbol \ref ALIB_FEAT_SINGLETON_MAPPED is \c true.
71 ///
72 /// The method included with \alibheader{singletons/dbgsingletons.hpp}.
73 ///
74 /// \note
75 /// In case module <b>%ALib Strings</b> is not available, then alternative method
76 /// \alib{singletons;DbgGetSingletons} can be used. This returns a list of
77 /// \c std::type_info structs together with (void-) pointers to the singletons.
78 ///
79 /// @param target The target string to write the list of singletons to.
80 ///
81 /// @return The number of singletons written.
82 //=========================================================================================
83 ALIB_API int DbgGetSingletons( NAString& target );
84 #endif // ALIB_STRINGS
85
86} // namespace [alib::singletons]
87
88
89#endif // ALIB_FEAT_SINGLETON_MAPPED && ALIB_DEBUG
90#endif // HPP_ALIB_SINGLETONS_DBGSINGLETONS
91
#define ALIB_API
Definition alib.hpp:639
@ Auto
Auto/default mode.
ALIB_API HashMap< MonoAllocator, TypeFunctors::Key, void *, TypeFunctors::Hash, TypeFunctors::EqualTo, lang::Caching::Auto, Recycling::None > & DbgGetSingletons()
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
Comparison functor for type const std::type_info*.
Hash code functor for type const std::type_info*.
const ::std::type_info * Key
The key type.