ALib C++ Library
by
Library Version:
2412 R0
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
singletons
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
11
#include "
alib/singletons/singleton.hpp
"
12
#if ALIB_FEAT_SINGLETON_MAPPED && ALIB_DEBUG
13
14
#include "
alib/compatibility/std_typeinfo.hpp
"
15
#if ALIB_MONOMEM && ALIB_CONTAINERS
16
# include "
alib/containers/hashtable.hpp
"
17
# include "
alib/monomem/monoallocator.hpp
"
18
#else
19
# include <unordered_map>
20
# include <mutex>
21
# include <cstring>
22
#endif
23
namespace
alib::singletons
{
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
//==============================================================================================
47
ALIB_API
HashMap
<
MonoAllocator
,
48
TypeFunctors::Key
,
void
*,
49
TypeFunctors::Hash
,
50
TypeFunctors::EqualTo
,
51
lang::Caching::Auto
,
52
Recycling::None >&
DbgGetSingletons
();
53
#else
54
ALIB_API
std::unordered_map<
TypeFunctors::Key
,
void
*,
55
TypeFunctors::Hash
,
56
TypeFunctors::EqualTo
>&
DbgGetSingletons
();
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
alib::containers::HashTable
Definition
hashtable.hpp:459
alib::strings::TAString< nchar, lang::HeapAllocator >
ALIB_API
#define ALIB_API
Definition
alib.hpp:639
hashtable.hpp
monoallocator.hpp
alib::lang::Caching::Auto
@ Auto
Auto/default mode.
alib::singletons
Definition
dbgsingletons.hpp:23
alib::singletons::DbgGetSingletons
ALIB_API HashMap< MonoAllocator, TypeFunctors::Key, void *, TypeFunctors::Hash, TypeFunctors::EqualTo, lang::Caching::Auto, Recycling::None > & DbgGetSingletons()
Definition
singleton.cpp:179
alib::MonoAllocator
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
Definition
boxing/fwds.hpp:31
singleton.hpp
std_typeinfo.hpp
alib::compatibility::std::TypeFunctors::EqualTo
Comparison functor for type const std::type_info*.
Definition
std_typeinfo.hpp:72
alib::compatibility::std::TypeFunctors::Hash
Hash code functor for type const std::type_info*.
Definition
std_typeinfo.hpp:58
alib::compatibility::std::TypeFunctors::Key
const ::std::type_info * Key
The key type.
Definition
std_typeinfo.hpp:52