ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::singletons Namespace Reference

Description:

This is the namespace of ALib Module "Singletons". Please refer to the Programmer's Manual Of ALib Singletons for information about using this (single :-) Singleton class in this tiny namespace.

Type Index:

class  Singleton
 

Function Index:

ALIB_API HashMap< MonoAllocator, TypeFunctors::Key, void *, TypeFunctors::Hash, TypeFunctors::EqualTo, lang::Caching::Auto, Recycling::None > & DbgGetSingletons ()
 
ALIB_API int DbgGetSingletons (NAString &target)
 
void Shutdown ()
 

Function Details:

◆ DbgGetSingletons() [1/2]

This debug helper function returns a type map with void pointers to all singletons.

The function may be used to investigate which singleton objects are created within a process and the point in (run-) time of creation.

Note
This method is available only with debug-builds of ALib and if code selection symbol ALIB_FEAT_SINGLETON_MAPPED evaluates to true.
The method included with alib/singletons/dbgsingletons.hpp.
If the ALib Distribution includes ALib Strings then a simple dumping method is available with DbgGetSingletons(NAString&).
Attention
If modules ALib Monomem and ALib Containers are not included in the ALib Distribution, then the result type of this method changes to std::unordered_map<TypeKey, void*>&.
Returns
A map of singleton types with void pointers to the singletons.

Definition at line 179 of file singleton.cpp.

◆ DbgGetSingletons() [2/2]

int DbgGetSingletons ( NAString & target)

This debug function writes all type names and addresses of each currently defined instance of class Singleton into the given AString.

Note
This method is available only

The method included with alib/singletons/dbgsingletons.hpp.

Note
In case module ALib Strings is not available, then alternative method DbgGetSingletons can be used. This returns a list of std::type_info structs together with (void-) pointers to the singletons.
Parameters
targetThe target string to write the list of singletons to.
Returns
The number of singletons written.

Definition at line 187 of file singleton.cpp.

Here is the call graph for this function:

◆ Shutdown()

ALIB_API void Shutdown ( )

Deletes the singletons. Upon exit of the process, programmers might want to explicitly free the hash table to avoid the detection of memory leaks by metrics tools like Valgrind . (Otherwise this can be omitted, as the memory is cleaned by the OS probably much faster when a process exits).

The standard bootstrap code of ALib, hence the (overloaded) functions alib::Shutdown will call this function.

Note
This method is not thread-safe and hence must be called only on termination of the process when all threads which are using singletons are terminated.

Definition at line 149 of file singleton.cpp.