ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Public Methods | Protected Methods | List of all members
ALibDistribution Class Reference

#include <distribution.hpp>

Inheritance diagram for ALibDistribution:
[legend]
Collaboration diagram for ALibDistribution:
[legend]

Class Description


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
 
- Public Fields inherited from Module
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 ()
 
- Public Methods inherited from Module
 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::ConfigurationGetConfig ()
 
const StringGetResource (const NString &name)
 
ResourcePoolGetResourcePool ()
 
bool IsBootstrapped ()
 
void operator= (const Module &)=delete
 
void operator= (Module &&)=delete
 
ALIB_API void Shutdown (ShutdownPhases targetPhase=ShutdownPhases::Destruct)
 
const StringTryResource (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

- Public Types inherited from Module
enum  BootstrapPhases { PrepareResources = 1, PrepareConfig = 2, Final = 3 }
 
enum  ShutdownPhases { Announce = 1, Destruct = 2 }
 
- Protected Static Fields inherited from Module
static bool microModulesInitialized = false
 
- Protected Fields inherited from Module
int bootstrapState = 0
 
config::Configurationconfig = nullptr
 
bool isConfigOwner = false
 
bool isResourceOwner = false
 
resources::ResourcePoolresourcePool = nullptr
 

Constructor & Destructor Documentation

◆ 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.

Member Function Documentation

◆ bootstrap()

void bootstrap ( BootstrapPhases  phase,
int  argc,
const char **  argv,
const wchar_t **  wargv 
)
overrideprotectedvirtual

Implementation of Module::bootstrap.

In phase BootstrapPhases::Final performs:

Parameters
phaseThe initialization phase to perform.
argcThe number of command line arguments. Defaults to 0.
argvList of command line arguments if given as single byte character strings.
wargvList of command line arguments if given as multi-byte character strings.

Implements Module.

Definition at line 215 of file distribution.cpp.

Here is the call graph for this function:

◆ BootstrapFillDefaultModuleList()

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.

◆ CheckDistribution()

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.

See also
For more information, see chapter 3.9 Assuring Compilation Compatibility of the ALib Programmer's Manual.
Parameters
alibVersionThe ALib version required. Defaults to ALIB_VERSION and should not be passed.
compilationFlagsThe 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.

Here is the call graph for this function:

◆ IsDebuggerPresent()

bool IsDebuggerPresent ( )

If true, the current process is under the hood of a debugger.

Note
This method is available only if module ALib System is included in the ALib Distribution.
Returns
true if the application is run in a debugger.

Definition at line 576 of file distribution.cpp.

Here is the call graph for this function:

◆ shutdown()

void shutdown ( ShutdownPhases  phase)
overrideprotectedvirtual

Terminates this module.

Parameters
phaseThe shutdown phase to perform.

Implements Module.

Definition at line 532 of file distribution.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ ArgC

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.

◆ ArgVN

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.

◆ ArgVW

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.

◆ HasConsoleWindow

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

  • If configuration variable ALIB_HAS_CONSOLE_WINDOW is set, its value is returned.
  • Otherwise, on Unix like OStrue is returned.
  • On Windows OS it is determined if a console window is attached to the process using system call GetConsoleWindow() and compare its result to NULL.

In addition, this public flag may be modified at run-time (after method Bootstrap was invoked).

Note
The evaluation of configuration variable ALIB_HAS_CONSOLE_WINDOW is done only if module ALib Configuration is included in the ALib Distribution.

Definition at line 230 of file lib/fs_modules/distribution.hpp.

◆ LocaleFound

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.

◆ Modules

List<Module*> Modules

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.

See also
Chapter 3.3 Class ALibDistribution and the following ones to learn about how to customize bootstrapping in various ways.

Definition at line 199 of file lib/fs_modules/distribution.hpp.

◆ WaitForKeyPressOnTermination

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.


The documentation for this class was generated from the following files: