ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
bootstrap.mpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4/// With supporting legacy or module builds, .mpp-files are either recognized by the build-system
5/// as C++20 Module interface files, or are included by the
6/// \ref alib_manual_modules_impludes "import/include headers".
7///
8/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
9/// Published under \ref mainpage_license "Boost Software License".
10//==================================================================================================
11#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
12# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
13#endif
14#if ALIB_C20_MODULES
15 module;
16#endif
17//========================================= Global Fragment ========================================
27
28
29//============================================== Module ============================================
30#if ALIB_C20_MODULES
31 /// This is a <em><b>C++ Module</b></em> of the \aliblong.
32 /// Due to the dual-compile option (either as C++20 Modules or using legacy C++ inclusion),
33 /// the C++20 Module names are not of further interest or use.<br>
34 /// In general, the names equal the names of the header files listed in the chapter
35 /// \ref alib_manual_modules_impludes of the \alib User Manual.
36 ///
37 /// @see The documentation of the <em><b>"ALib Module"</b></em> given with the corresponding
38 /// Programmer's Manual \alib_bootstrap.
39 export module ALib.Bootstrap;
40 import ALib.Lang;
41# if ALIB_CONTAINERS
42 import ALib.Containers.List;
43# endif
44# if ALIB_CAMP
45 import ALib.Monomem;
46 import ALib.Camp;
47# endif
48
49#else
50 #include "ALib.Lang.H"
51 #include "ALib.Containers.List.H"
52 #include "ALib.Monomem.H"
53 #include "ALib.Camp.H"
54#endif
55
56//============================================= Exports ============================================
57ALIB_EXPORT namespace alib {
58
59/// State of initialization of the \alibmods that do not dispose over a \alib{camp::Camp}
60/// instance.
62
63//##################################################################################################
64// Compilation flags
65// Create a bitset from the ALib compilation features.
66// For this, we ensure that the individual headers tested are included
67//##################################################################################################
68
69/// This is a struct composing an entry in #COMPILATION_FLAG_MEANINGS.
71{
72 int Flag; ///< The bit number in the bitset.
73 const char* Name; ///< The human-readable meaning of the bit.
74};
75
76/// This is for the creation of output on information about the bits found in
77/// field #COMPILATION_FLAGS.
78/// Declared public to allow exposure, e.g., in verbose logging.
79/// \see Method #AssertALibVersionAndFlags for more information.
80extern ALIB_DLL
82
83
84/// The module version. Standard \alib versioning scheme is YYMM (as integer number)
85/// of the module release date.
86/// Besides this version number, field #REVISION indicates if this is a revised version
87/// of a former release.
88extern ALIB_DLL
89int VERSION;
90
91/// The revision number of this release. Usually a module is initially released as
92/// revision \e 0. Pure bug-fix releases that do not change the interface of \alib
93/// are holding the same #VERSION but an increased number in this field.
94extern ALIB_DLL
95unsigned char REVISION;
96
97/// These flags are used internally to detect incompatibilities when linking \alib to binaries that
98/// use different compilation flags. Declared public to allow exposure, e.g., in verbose logging.
99/// \see Function #AssertALibVersionAndFlags, which is invoked by overloaded functions
100/// #Bootstrap.
101extern ALIB_DLL
103
104/// Compares a given set of compilation flags with the ones set in the \alib library.
105/// If a mismatch is found, the configuration mismatch is written to <c>std::cerr</c>
106/// and <c>exit(255)</c> is performed.
107///
108/// This function called in all variants of function \ref alib::Bootstrap.
109/// If a using application wants to act different on such a mismatch, an own check of
110/// global variables \ref alib::VERSION, \ref alib::REVISION and \ref alib::COMPILATION_FLAGS against
111/// preprocessor symbols \ref ALIB_VERSION, \ref ALIB_REVISION and
112/// \doxlinkproblem{group__GrpALibPreproMacros.html;gaac71b6511690f5af0abf5213b0434111;ALIB_COMPILATION_FLAGS;ALIB_COMPILATION_FLAGS}
113/// has to be performed \e before calling \b Bootstrap.
114///
115/// \attention A mismatch in \alib library version and compilation flags, may lead to very
116/// dubious misbehavior which is almost impossible to debug. This is true for any
117/// C/C++ software/library mismatch.
118///
119/// @param alibVersion The \alib version required.
120/// Defaults to \ref ALIB_VERSION and \b must not be passed when invoking
121/// this function.
122/// @param alibRevision The \alib sub-version required.
123/// Defaults to \ref ALIB_REVISION and \b must not be passed when invoking
124/// this function.
125/// @param compilationFlags The flags as defined in invoking compilation unit.
126/// Defaults to \c ALIB_COMPILATION_FLAGS and \b must not be given.
128void AssertALibVersionAndFlags( int alibVersion = ALIB_VERSION,
129 int alibRevision = ALIB_REVISION,
130 TCompilationFlags compilationFlags= TCompilationFlags{ALIB_COMPILATION_FLAGS} );
131
132//==================================================================================================
133//========================================= Non-Camp Version =======================================
134//==================================================================================================
135#if !ALIB_CAMP || DOXYGEN
136/// Performs standard bootstrapping of \alib. All details are explained
137/// in the \ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
138///
139/// \note In addition, function \ref alib::AssertALibVersionAndFlags is invoked.
140/// For this, the parameters of this function must not be given, but left to their
141/// default values, which are read from corresponding preprocessor symbols.<br>
142/// For more information on this topic, see chapter
143/// \ref alib_mod_bs_assertcomp of the \ref alib_manual.
144///
145/// \par Availability
146/// This function is replaced by a sibling method of the same name, but with more parameters,
147/// in case the module \alib_camp is included in the \alibbuild.
148///
149/// @param alibVersion The \alib version used by the caller.
150/// Defaults to \ref ALIB_VERSION and \b must not be passed.
151/// @param alibRevision The \alib sub-version used by the caller.
152/// Defaults to \ref ALIB_REVISION and \b must not be passed.
153/// @param compilationFlags The flags as defined in invoking compilation unit.
154/// Defaults to
155/// \doxlinkproblem{group__GrpALibPreproMacros.html;gaac71b6511690f5af0abf5213b0434111;ALIB_COMPILATION_FLAGS;ALIB_COMPILATION_FLAGS}
156/// and \b must not be passed.
157ALIB_DLL void Bootstrap(int alibVersion = ALIB_VERSION,
158 int alibRevision = ALIB_REVISION,
159 TCompilationFlags compilationFlags = TCompilationFlags{ALIB_COMPILATION_FLAGS});
160
161/// Terminates \alib. All details are explained in the
162/// \ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
163/// \par Availability
164/// This function is replaced by a sibling method of the same name, but with more parameters,
165/// in case the module \alib_camp is included in the \alibbuild.
167#endif
168
169//==================================================================================================
170//=========================================== Camp Version =========================================
171//==================================================================================================
172#if ALIB_CAMP || DOXYGEN
173/// Lists all \alibcamps in the order of bootstrapping. Shutdown is performed in reverse order.
174/// This list is used by overloaded functions
175/// - \doxlinkproblem{namespacealib.html;a78bb34888e5142adb87e265e23ee3c2e;alib::Bootstrap(BootstrapPhases, camp::Camp*, int,int,TCompilationFlags)},
176/// and
177/// - \doxlinkproblem{namespacealib.html;a4374717714582ef1a859b773367ec5d9;alib::Shutdown(ShutdownPhases, camp::Camp*)}.
178///
179/// For details on when and how to manipulate this list explicitly, see the detailed explanations in
180/// the \\ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
181///
182/// \note Should for any reason it is needed to \b not use method \alib{BootstrapAddDefaultCamps}
183/// to default-fill this list before adding custom camps, then the allocator of this
184/// list has to be set before filling it. This can be done with:
185///
186/// CAMPS.GetAllocator()= monomem::GLOBAL_ALLOCATOR;
189
190/// Fills list \ref alib::CAMPS, taking the permutation of modules contained in the \alibbuild into
191/// account.<br>
192/// This function is usually invoked automatically.
193///
194/// For details on when and how to explicitly invoke this function, see the detailed explanations
195/// in the \ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
198
199//==================================================================================================
200/// This function is used to bootstrap \alib. It replaces the overloaded version
201/// #Bootstrap(int, int, TCompilationFlags) in the moment module \alib_camp is included in the
202/// \alibbuild.
203/// (The term "replace" here in deed means that this other version of this function is not available
204/// anymore.)
205///
206/// The difference of this version is that it makes it possible to fine-tune the bootstrap
207/// process in respect to the list of camps that are considered and it introduces
208/// different phases of bootstrapping.
209///
210/// For details on when and how to invoke this method explicitly, see the detailed explanations in
211/// the \ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
212///
213/// @param targetPhase The initialization level to perform.
214/// Defaults to <c>BootstrapPhases::Final</c>.
215/// @param targetCamp The "highest" \alibcamp in the list \alib{CAMPS} to bootstrap.
216/// Defaults to <c>nullptr</c>, which chooses the end of the list.
217/// @param alibVersion The \alib version required.
218/// Defaults to \ref ALIB_VERSION and \b must not be passed when invoking
219/// this function.
220/// @param alibRevision The \alib sub-version required.
221/// Defaults to \ref ALIB_REVISION and \b must not be passed when invoking
222/// this function.
223/// @param compilationFlags The flags as defined in invoking compilation unit.
224/// Defaults to
225/// \doxlinkproblem{group__GrpALibPreproMacros.html;gaac71b6511690f5af0abf5213b0434111;ALIB_COMPILATION_FLAGS;ALIB_COMPILATION_FLAGS}
226/// and must not be passed when
227/// invoking this function.
228//==================================================================================================
231 camp::Camp* targetCamp = nullptr,
232 int alibVersion = ALIB_VERSION,
233 int alibRevision = ALIB_REVISION,
234 TCompilationFlags compilationFlags= TCompilationFlags{ALIB_COMPILATION_FLAGS});
235
236//==================================================================================================
237/// This function is usually invoked automatically and rightfully with the standard, parameterless
238/// version \ref alib::Shutdown().
239///
240/// For details on when and how to invoke this method explicitly, see the detailed explanations in
241/// the \ref alib_mod_bs "Programmer's Manual" of module \alib_bootstrap_nl.
242///
243/// @param targetPhase The termination level to perform.
244/// @param targetCamp The "lowest" \alibcamp in list \alib{CAMPS} to shut down.
245/// Defaults to <c>nullptr</c>, which chooses the start of the list.
246//==================================================================================================
249 camp::Camp* targetCamp = nullptr );
250#endif
251
252} // namespace [alib]
#define ALIB_DLL
Definition alib.inl:503
#define ALIB_REVISION
Definition alib.inl:21
#define ALIB_VERSION
Definition alib.inl:20
#define ALIB_EXPORT
Definition alib.inl:497
CompilationFlagMeaningsEntry COMPILATION_FLAG_MEANINGS[40]
void AssertALibVersionAndFlags(int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
unsigned char REVISION
BootstrapPhases
Definition camp.inl:15
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
Definition camp.inl:35
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
Definition list.inl:693
void BootstrapAddDefaultCamps()
ALIB_DLL ListMA< camp::Camp * > CAMPS
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition camp.inl:42
@ Destruct
The main phase of termination that destructs everything.
Definition camp.inl:46
void Bootstrap(BootstrapPhases targetPhase, camp::Camp *targetCamp, int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
int VERSION
bool NonCampModulesInitialized
TCompilationFlags COMPILATION_FLAGS
ALIB_DLL void Shutdown()
This is a struct composing an entry in COMPILATION_FLAG_MEANINGS.
Definition bootstrap.mpp:71
const char * Name
The human-readable meaning of the bit.
Definition bootstrap.mpp:73
int Flag
The bit number in the bitset.
Definition bootstrap.mpp:72