ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
bootstrap.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_bootstrap of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8ALIB_EXPORT namespace alib {
9
10/// State of initialization of the \alibmods that do not dispose over a #"Camp"
11/// instance.
13
14//##################################################################################################
15// Compilation flags
16// Create a bitset from the ALib compilation features.
17// For this, we ensure that the individual headers tested are included
18//##################################################################################################
19
20/// This is a simple copyable set of bits comprising the compilation flags.
21/// @see Used with methods #"Bootstrap" which calls #"AssertALibVersionAndFlags".
23 unsigned char bits[5]; ///< The Flags.
24};
25
26/// This is a struct composing an entry in #"COMPILATION_FLAG_MEANINGS".
28 int Flag; ///< The bit number in the bitset.
29 const char* Name; ///< The human-readable meaning of the bit.
30};
31
32/// This is for the creation of output on information about the bits found in
33/// field #"COMPILATION_FLAGS".
34/// Declared public to allow exposure, e.g., in verbose logging.
35/// \see Method #"AssertALibVersionAndFlags" for more information.
36extern ALIB_DLL
38
39
40/// The module version. Standard \alib versioning scheme is YYMM (as integer number)
41/// of the module release date.
42/// Besides this version number, field #"REVISION" indicates if this is a revised version
43/// of a former release.
44extern ALIB_DLL
45int VERSION;
46
47/// The revision number of this release. Usually a module is initially released as
48/// revision \e 0. Pure bug-fix releases that do not change the interface of \alib
49/// are holding the same #"VERSION" but an increased number in this field.
50extern ALIB_DLL
51unsigned char REVISION;
52
53/// These flags are used internally to detect incompatibilities when linking \alib to binaries that
54/// use different compilation flags. Declared public to allow exposure, e.g., in verbose logging.
55/// \see Function #"AssertALibVersionAndFlags", which is invoked by overloaded functions
56/// #"Bootstrap".
57extern ALIB_DLL
59
60/// Compares a given set of compilation flags with the ones set in the \alib library.
61/// If a mismatch is found, the configuration mismatch is written to <c>std::cerr</c>
62/// and <c>exit(255)</c> is performed.
63///
64/// This function called in all variants of function #"Bootstrap(BootstrapPhases);2".
65/// If a using application wants to act different on such a mismatch, an own check of
66/// global variables #"VERSION;2", #"REVISION;2" and #"COMPILATION_FLAGS;2" against
67/// configuration macros #"ALIB_VERSION", #"ALIB_REVISION" and
68/// #"ALIB_COMPILATION_FLAGS"
69/// has to be performed \e before calling #"%Bootstrap".
70///
71/// \attention A mismatch in \alib library version and compilation flags, may lead to very
72/// dubious misbehavior which is almost impossible to debug. This is true for any
73/// C/C++ software/library mismatch.
74///
75/// @param alibVersion The \alib version required.
76/// Defaults to #"ALIB_VERSION" and <b>must not</b> be passed when invoking
77/// this function.
78/// @param alibRevision The \alib sub-version required.
79/// Defaults to #"ALIB_REVISION" and <b>must not</b> be passed when invoking
80/// this function.
81/// @param compilationFlags The flags as defined in invoking compilation unit.
82/// Defaults to \c ALIB_COMPILATION_FLAGS and must not be given.
84void AssertALibVersionAndFlags( int alibVersion = ALIB_VERSION,
85 int alibRevision = ALIB_REVISION,
87
88//==================================================================================================
89//========================================= Non-Camp Version =======================================
90//==================================================================================================
91#if !ALIB_CAMP || DOXYGEN
92/// Performs standard bootstrapping of \alib. All details are explained
93/// in the #"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
94///
95/// \note In addition, function #"AssertALibVersionAndFlags;2" is invoked.
96/// For this, the parameters of this function must not be given, but left to their
97/// default values, which are read from corresponding configuration macros.<br>
98/// For more information on this topic, see chapter
99/// #"alib_mod_bs_assertcomp" of the #"alib_manual".
100///
101/// \par Availability
102/// This function is replaced by a sibling method of the same name, but with more parameters,
103/// in case the module \alib_camp is included in the \alibbuild.
104///
105/// @param alibVersion The \alib version used by the caller.
106/// Defaults to #"ALIB_VERSION" and <b>must not</b> be passed.
107/// @param alibRevision The \alib sub-version used by the caller.
108/// Defaults to #"ALIB_REVISION" and <b>must not</b> be passed.
109/// @param compilationFlags The flags as defined in invoking compilation unit.
110/// Defaults to #"ALIB_COMPILATION_FLAGS" and <b>must not</b> be passed.
111ALIB_DLL void Bootstrap(int alibVersion = ALIB_VERSION,
112 int alibRevision = ALIB_REVISION,
114
115/// Terminates \alib. All details are explained in the
116/// #"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
117/// \par Availability
118/// This function is replaced by a sibling method of the same name, but with more parameters,
119/// in case the module \alib_camp is included in the \alibbuild.
121#endif
122
123//==================================================================================================
124//=========================================== Camp Version =========================================
125//==================================================================================================
126#if ALIB_CAMP || DOXYGEN
127/// Lists all \alibcamps in the order of bootstrapping. Shutdown is performed in reverse order.
128/// This list is used by overloaded functions
129/// - #"Bootstrap(BootstrapPhases, camp::Camp*, int, int, TCompilationFlags);2", and
130/// - #"Shutdown(ShutdownPhases, camp::Camp*);2".
131///
132/// For details on when and how to manipulate this list explicitly, see the detailed explanations in
133/// the \#"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
134///
135/// \note Should for any reason it is needed to \b not use method #"BootstrapAddDefaultCamps;2"
136/// to default-fill this list before adding custom camps, then the allocator of this
137/// list has to be set before filling it. This can be done with:
138///
139/// CAMPS.GetAllocator()= monomem::GLOBAL_ALLOCATOR;
142
143/// Fills list #"CAMPS;2", taking the permutation of modules contained in the \alibbuild into
144/// account.<br>
145/// This function is usually invoked automatically.
146///
147/// For details on when and how to explicitly invoke this function, see the detailed explanations
148/// in the #"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
151
152//==================================================================================================
153/// This function is used to bootstrap \alib. It replaces the overloaded version
154/// #"Bootstrap(int", int, TCompilationFlags) in the moment module \alib_camp is included in the
155/// \alibbuild.
156/// (The term "replace" here in deed means that this other version of this function is not available
157/// anymore.)
158///
159/// The difference of this version is that it makes it possible to fine-tune the bootstrap
160/// process in respect to the list of camps that are considered and it introduces
161/// different phases of bootstrapping.
162///
163/// For details on when and how to invoke this method explicitly, see the detailed explanations in
164/// the #"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
165///
166/// @param targetPhase The initialization level to perform.
167/// Defaults to <c>BootstrapPhases::Final</c>.
168/// @param targetCamp The "highest" \alibcamp in the list #"CAMPS;2" to bootstrap.
169/// Defaults to <c>nullptr</c>, which chooses the end of the list.
170/// @param alibVersion The \alib version required.
171/// Defaults to #"ALIB_VERSION" and <b>must not</b> be passed when invoking
172/// this function.
173/// @param alibRevision The \alib sub-version required.
174/// Defaults to #"ALIB_REVISION" and <b>must not</b> be passed when invoking
175/// this function.
176/// @param compilationFlags The flags as defined in invoking compilation unit.
177/// Defaults to #"ALIB_COMPILATION_FLAGS" and <b>must not</b> be passed when
178/// invoking this function.
179//==================================================================================================
182 camp::Camp* targetCamp = nullptr,
183 int alibVersion = ALIB_VERSION,
184 int alibRevision = ALIB_REVISION,
186
187//==================================================================================================
188/// This function is usually invoked automatically and rightfully with the standard, parameterless
189/// version #"alib::Shutdown(").
190///
191/// For details on when and how to invoke this method explicitly, see the detailed explanations in
192/// the #"alib_mod_bs;Programmer's Manual" of module \alib_bootstrap_nl.
193///
194/// @param targetPhase The termination level to perform.
195/// @param targetCamp The "lowest" \alibcamp in list #"CAMPS;2" to shut down.
196/// Defaults to <c>nullptr</c>, which chooses the start of the list.
197//==================================================================================================
200 camp::Camp* targetCamp = nullptr );
201#endif
202
203} // namespace [alib]
#define ALIB_DLL
#define ALIB_REVISION
#define ALIB_VERSION
#define ALIB_EXPORT
#define ALIB_COMPILATION_FLAGS
Definition alox.cpp:14
ListMA< camp::Camp * > CAMPS
BootstrapPhases
Definition camp.hpp:14
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
Definition camp.hpp:34
void BootstrapAddDefaultCamps()
void Bootstrap(BootstrapPhases targetPhase, camp::Camp *targetCamp, int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
CompilationFlagMeaningsEntry COMPILATION_FLAG_MEANINGS[40]
Definition bootstrap.cpp:12
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace #"%alib".
Definition list.hpp:689
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
Definition camp.hpp:40
@ Destruct
The main phase of termination that destructs everything.
Definition camp.hpp:44
TCompilationFlags COMPILATION_FLAGS
Definition bootstrap.cpp:10
int VERSION
Definition bootstrap.cpp:8
void Shutdown()
bool NonCampModulesInitialized
void AssertALibVersionAndFlags(int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
Definition bootstrap.cpp:60
unsigned char REVISION
Definition bootstrap.cpp:9
This is a struct composing an entry in #"COMPILATION_FLAG_MEANINGS".
Definition bootstrap.hpp:27
const char * Name
The human-readable meaning of the bit.
Definition bootstrap.hpp:29
int Flag
The bit number in the bitset.
Definition bootstrap.hpp:28
unsigned char bits[5]
The Flags.
Definition bootstrap.hpp:23