#include <distribution.hpp>
This is a special module singleton that provides some "knowledge" about the modules contained in a distribution. It offers method BootstrapFillDefaultModuleList which is used by method Module::Bootstrap in the case that the module list was not externally customized and filled already.
Usually, this module is the one that method Module::Bootstrap is invoked on. All details on this topic are given in chapter 3. Bootstrapping ALib of the ALib Programmer's Manual.
Besides that, the class provides a few utility members that have not found a different home with the current version of the library.
This is a strict singleton class. The only instance is found with namespace variable aworx::ALIB.
Definition at line 180 of file lib/fs_modules/distribution.hpp.
Public Fields | |
int | ArgC = 0 |
const char ** | ArgVN = nullptr |
const wchar_t ** | ArgVW = nullptr |
bool | HasConsoleWindow |
String | LocaleFound |
List< Module * > | Modules |
bool | WaitForKeyPressOnTermination =false |
![]() | |
std::vector< std::pair< const nchar *, uint64_t > > | CompilationFlagMeanings |
const uint64_t | CompilationFlags |
NCString | ResourceCategory |
const int | Revision |
const int | Version |
Public Methods | |
ALibDistribution () | |
ALIB_API void | BootstrapFillDefaultModuleList () |
ALIB_API void | CheckDistribution (int alibVersion=ALIB_VERSION, uint64_t compilationFlags=ALIB_COMPILATION_FLAGS) |
ALIB_API bool | IsDebuggerPresent () |
![]() | |
Module (const Module &)=delete | |
Module (int version, int revision, const NCString &resourceCategory, uint64_t compilationFlags=0) | |
Module (Module &&)=delete | |
virtual | ~Module () |
ALIB_API bool | Bootstrap (BootstrapPhases targetPhase=BootstrapPhases::Final, int argc=0, const char **argvN=nullptr, const wchar_t **argvW=nullptr) |
template<typename TChar > | |
bool | Bootstrap (int argc, TChar **argv, BootstrapPhases targetPhase=BootstrapPhases::Final) |
void | BootstrapResource (const NString &name, const String &data) |
void | BootstrapSetConfig (config::Configuration *pConfig) |
void | BootstrapSetResourcePool (resources::ResourcePool *pool) |
config::Configuration & | GetConfig () |
const String & | GetResource (const NString &name) |
ResourcePool & | GetResourcePool () |
bool | IsBootstrapped () |
void | operator= (const Module &)=delete |
void | operator= (Module &&)=delete |
ALIB_API void | Shutdown (ShutdownPhases targetPhase=ShutdownPhases::Destruct) |
const String & | TryResource (const NString &name) |
ALIB_API bool | VerifyCompilationFlags (uint64_t compilationFlags) |
Protected Methods | |
virtual void | bootstrap (BootstrapPhases phase, int argc, const char **argv, const wchar_t **wargv) override |
virtual void | shutdown (ShutdownPhases phase) override |
Additional Inherited Members | |
![]() | |
enum | BootstrapPhases { PrepareResources = 1, PrepareConfig = 2, Final = 3 } |
enum | ShutdownPhases { Announce = 1, Destruct = 2 } |
![]() | |
static bool | microModulesInitialized = false |
![]() | |
int | bootstrapState = 0 |
config::Configuration * | config = nullptr |
bool | isConfigOwner = false |
bool | isResourceOwner = false |
resources::ResourcePool * | resourcePool = nullptr |
ALibDistribution | ( | ) |
Constructor.
While this is public, it must not be invoked as this is a strict singleton type. (See notes in 3.2.1 Singletons).
Definition at line 133 of file distribution.cpp.
|
overrideprotectedvirtual |
Implementation of Module::bootstrap.
In phase BootstrapPhases::Final performs:
In glibc versions of ALib (GNU/unix) probably invoke glibc method setlocale(), depending on the setting of the environment variables LANG and LANGUAGE and depending on ALib configuration variable ALIB_LOCALE .
In addition, invokes NumberFormat::SetFromLocale on static singleton NumberFormat::Global.
phase | The initialization phase to perform. |
argc | The number of command line arguments. Defaults to 0 . |
argv | List of command line arguments if given as single byte character strings. |
wargv | List of command line arguments if given as multi-byte character strings. |
Implements Module.
Definition at line 215 of file distribution.cpp.
void BootstrapFillDefaultModuleList | ( | ) |
Fills list Modules, taking the permutation of modules contained in the ALib Distribution into account.
Definition at line 191 of file distribution.cpp.
void CheckDistribution | ( | int | alibVersion = ALIB_VERSION , |
uint64_t | compilationFlags = ALIB_COMPILATION_FLAGS |
||
) |
Checks the versions of ALib and whether the current compilation unit shares compatible compiler symbols with the ALib binaries. The latter is done by invoking inherited method Module::VerifyCompilationFlags.
This method should be invoked in the bootstrap code of your processes and libraries to check for compilation and linkage mismatch.
Parameter alibVersion defaults to macro ALIB_VERSION and parameter compilationFlags to macro ALIB_COMPILATION_FLAGS. Both parameters should not be given when invoked. This value is internally matched against what they were when ALib was compiled.
alibVersion | The ALib version required. Defaults to ALIB_VERSION and should not be passed. |
compilationFlags | The flags as defined in invoking compilation unit. Defaults to ALIB_COMPILATION_FLAGS and should not be passed. |
Definition at line 612 of file distribution.cpp.
bool IsDebuggerPresent | ( | ) |
If true
, the current process is under the hood of a debugger.
true
if the application is run in a debugger. Definition at line 576 of file distribution.cpp.
|
overrideprotectedvirtual |
Terminates this module.
phase | The shutdown phase to perform. |
Implements Module.
Definition at line 532 of file distribution.cpp.
int ArgC = 0 |
The command line arguments stored for convenience. Only available, if (recursive) module initialization was performed with aworx::lib::Module::Bootstrap(int:: nchar** "BootstrapPhases)" or aworx::lib::Module::Bootstrap(int:: wchar** "BootstrapPhases)".
Definition at line 246 of file lib/fs_modules/distribution.hpp.
const char** ArgVN = nullptr |
The command line arguments stored for convenience. Only available, if (recursive) module initialization was performed with aworx::lib::Module::Bootstrap(int:: char** "BootstrapPhases)".
Definition at line 253 of file lib/fs_modules/distribution.hpp.
const wchar_t** ArgVW = nullptr |
The command line arguments stored for convenience. Only available, if (recursive) module initialization was performed with aworx::lib::Module::Bootstrap(int:: wchar_t** "BootstrapPhases)".
Definition at line 260 of file lib/fs_modules/distribution.hpp.
bool HasConsoleWindow |
This flag indicates if the current process has console output window attached. While this is not detectable in Unix like systems (or just with huge efforts), in windows it is. The determination is performed in bootstrap and done as follows
true
is returned.In addition, this public flag may be modified at run-time (after method Bootstrap was invoked).
Definition at line 230 of file lib/fs_modules/distribution.hpp.
String LocaleFound |
This string is set during bootstrapping in the case that a locale information was found (via standard environment variables or ALib variable LOCALE) and successfully set.
Otherwise this string is nulled.
Definition at line 238 of file lib/fs_modules/distribution.hpp.
Lists all modules in the order of bootstrapping. Shutdown is performed in reverse order. This list is used by method Module::Bootstrap, regardless on which module it was invoked. If the list is empty at the time of invocation, method Module::Bootstrap will use this class's method BootstrapFillDefaultModuleList to fill it with the default ALib modules in the right order.
To customize the list (append own modules), method BootstrapFillDefaultModuleList may be invoked prior to Module::Bootstrap and afterwards the list might be extended.
Definition at line 199 of file lib/fs_modules/distribution.hpp.
bool WaitForKeyPressOnTermination =false |
If true
, within Shutdown, it is waited for a key press in the console window.
By default, this flag is enabled when debugging a console application under Visual Studio.
This default behavior can be overruled by setting configuration variable ALIB_WAIT_FOR_KEY_PRESS .
In addition, this public flag may be modified at run-time (after method Bootstrap was invoked).
Definition at line 211 of file lib/fs_modules/distribution.hpp.