8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
24#if ALIB_DEBUG && !DOXYGEN
25# if defined(__GNUC__) || defined(__clang__)
40# if defined( _WIN32 ) && !defined(_STRING_)
50#if (ALIB_SINGLE_THREADED && ALIB_EXT_LIB_THREADS_AVAILABLE)
56 module ALib.Bootstrap;
67 import ALib.Singletons;
73 import ALib.EnumRecords.Bootstrap;
76 import ALib.ThreadModel;
79 import ALib.Exceptions;
86 import ALib.Format.StdImplementation;
87 import ALib.Format.FormatterPythonStyle;
88 import ALib.Format.FormatterJavaStyle;
92 import ALib.Camp.Base;
93 import ALib.Resources;
94 import ALib.Variables;
97 import ALib.BitBuffer;
101 import ALib.ALox.Impl;
104 import ALib.Expressions;
159 { 6,
"ENUMRECORDS" },
162 { 8,
"EXPRESSIONS" },
167 { 13,
"SINGLETONS" },
171 { 16,
"THREADMODEL" },
174 { 19,
"ALIB_DEBUG_ARRAY_COMPRESSION" },
175 { 20,
"ALIB_DEBUG_ALLOCATIONS" },
176 { 21,
"ALIB_DEBUG_BOXING" },
177 { 22,
"ALIB_DEBUG_CONTAINERS" },
178 { 23,
"ALIB_DEBUG_CRITICAL_SECTIONS" },
180 { 24,
"ALIB_DEBUG_MEMORY" },
181 { 25,
"ALIB_DEBUG_STRINGS" },
182 { 26,
"ALIB_DEBUG_RESOURCES" },
183 { 27,
"ALIB_C20_MODULES" },
184 { 28,
"ALIB_SINGLE_THREADED" },
185 { 29,
"FEAT_SINGLETON_MAPPED" },
186 { 30,
"CHARACTERS_WIDE" },
187 { 31,
"CHARACTERS_WCHAR_IS_4" },
189 { 32,
"FEAT_BOXING_BIJECTIVE_INTEGRALS" },
190 { 33,
"FEAT_BOXING_BIJECTIVE_CHARACTERS" },
191 { 34,
"FEAT_BOXING_BIJECTIVE_FLOATS" },
192 { 35,
"ALIB_FEAT_BOOST_REGEX" },
194 { 37,
"DBG_LOG_CI" },
196 { 39,
"REL_LOG_CI" },
204 std::cerr <<
"!!! Error in ALox library compilation: linked against wrong version of ALib" << std::endl;
205 std::cerr <<
"!!! ALib library version: " <<
VERSION <<
"R" << int(
REVISION) << std::endl;
206 std::cerr <<
"!!! ALib requested version: " << alibVersion <<
"R" << alibRevision << std::endl;
207 std::cerr <<
"!!! Exiting with exit(-1)" << std::endl;
218 std::cerr <<
"!!! Error in ALib library compilation: linked library of ALib has "
219 "different compiler-symbols set than the using executable (or library)." << std::endl;
222 std::cerr << std::left << std::setw(35) <<
"Symbol" <<
'|' << std::setw(5) <<
" Lib" <<
'|' <<
" Comp. Unit" << std::endl;
223 std::cerr<< std::setw(62) << std::setfill(
'-') <<
' ' << std::endl << std::setfill(
' ');
227 bool reqFlag= (compilationFlags.
bits[p.Flag/8] & (1 << (p.Flag % 8))) != 0;
229 std::cerr << std::setw(35) << p.Name <<
'|' << std::setw(5) << (libFlag ?
" On" :
" Off")
230 <<
"|" << std::setw(5) << (reqFlag ?
" On" :
" Off")
231 << ( libFlag != reqFlag ?
" <-- Mismatch! " :
"")
236 std::cerr <<
"!!! Exiting with exit(-1)" << std::endl;
265 # if !ALIB_SINGLE_THREADED
267 # if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
287DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS])
300DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS])
313DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS_2])
321DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS_2])
459#if !ALIB_SINGLE_THREADED
472 { system::SystemFolders::Root ,
A_CHAR(
"Root" ) , 1 },
473 { system::SystemFolders::Current ,
A_CHAR(
"Current" ) , 1 },
474 { system::SystemFolders::HomeConfig ,
A_CHAR(
"HomeConfig") , 5 },
475 { system::SystemFolders::Home ,
A_CHAR(
"Home" ) , 1 },
476 { system::SystemFolders::Module ,
A_CHAR(
"Module" ) , 1 },
477 { system::SystemFolders::Temp ,
A_CHAR(
"Temp" ) , 1 },
478 { system::SystemFolders::VarTemp ,
A_CHAR(
"VarTemp" ) , 1 },
498 { format::ByteSizeUnits::B ,
A_CHAR(
"B" ) , 3 },
499 { format::ByteSizeUnits::KiB ,
A_CHAR(
"KiB" ) , 3 },
500 { format::ByteSizeUnits::MiB ,
A_CHAR(
"MiB" ) , 3 },
501 { format::ByteSizeUnits::GiB ,
A_CHAR(
"GiB" ) , 3 },
502 { format::ByteSizeUnits::TiB ,
A_CHAR(
"TiB" ) , 3 },
503 { format::ByteSizeUnits::PiB ,
A_CHAR(
"PiB" ) , 3 },
504 { format::ByteSizeUnits::EiB ,
A_CHAR(
"EiB" ) , 3 },
505 { format::ByteSizeUnits::ZiB ,
A_CHAR(
"ZiB" ) , 3 },
506 { format::ByteSizeUnits::YiB ,
A_CHAR(
"YiB" ) , 3 },
507 { format::ByteSizeUnits::RiB ,
A_CHAR(
"RiB" ) , 3 },
508 { format::ByteSizeUnits::QiB ,
A_CHAR(
"QiB" ) , 3 },
509 { format::ByteSizeUnits::B ,
A_CHAR(
"B" ) , 1 },
510 { format::ByteSizeUnits::kB ,
A_CHAR(
"kB" ) , 2 },
511 { format::ByteSizeUnits::MB ,
A_CHAR(
"MB" ) , 2 },
512 { format::ByteSizeUnits::GB ,
A_CHAR(
"GB" ) , 2 },
513 { format::ByteSizeUnits::TB ,
A_CHAR(
"TB" ) , 2 },
514 { format::ByteSizeUnits::PB ,
A_CHAR(
"PB" ) , 2 },
515 { format::ByteSizeUnits::EB ,
A_CHAR(
"EB" ) , 2 },
516 { format::ByteSizeUnits::ZB ,
A_CHAR(
"ZB" ) , 2 },
517 { format::ByteSizeUnits::YB ,
A_CHAR(
"YB" ) , 2 },
518 { format::ByteSizeUnits::RB ,
A_CHAR(
"RB" ) , 2 },
519 { format::ByteSizeUnits::QB ,
A_CHAR(
"QB" ) , 2 },
525 "11,ArgumentIndexIs0," "Argument index 0 not allowed.\n"
526 "In: {!Q}\n >{!FillC-}^"
527 "," "12,ArgumentIndexOutOfBounds," "Argument index #{} is out of bounds. {} arguments are available.\n"
528 "In: {!Q}\n >{!FillC-}^"
529 "," "13,IncompatibleTypeCode," "Detected placeholder type does not match given argument.\n"
530 "Placeholder number: {}\n"
531 "Placeholder type: {} ({})"
532 "Placeholder type: {} ({})\n"
533 "Deduced argument type: {!Q}\n"
535 "In: {!Q}\n >{!FillC-}^"
537 "," "101,MissingClosingBracket," "Closing bracket '}}' of placeholder not found (or syntax error).\n"
538 "In: {!Q}\n >{!FillC-}^"
539 "," "102,MissingPrecisionValuePS," "Missing precision value after '.' character."
540 "\nIn: {!Q}\n >{!FillC-}^"
541 "," "103,DuplicateTypeCode," "Duplicate type code {!Q'} given (previous was {!Q'})."
543 "\nIn: {!Q}\n >{!FillC-}^"
544 "," "104,UnknownTypeCode," "Unknown type code {!Q'} given."
545 "\nIn: {!Q}\n >{!FillC-}^"
547 "," "105,ExclamationMarkExpected," "Expected '!' in continuation of placeholder."
549 "\nIn: {!Q}\n >{!FillC-}^"
550 "," "106,UnknownConversionPS," "Unknown conversion \"!{}\"."
552 "\nIn: {!Q}\n >{!FillC-}^"
553 "," "107,PrecisionSpecificationWithInteger," "Precision not allowed with integer format."
555 "\nIn: {!Q}\n >{!FillC-}^"
556 "," "108,MissingReplacementStrings," "Missing pair of replacement strings \"<src><repl>\" after \"!Replace\"."
558 "\nIn: {!Q}\n >{!FillC-}^"
560 "," "201,NegativeValuesInBracketsNotSupported," "Brackets for negative values not implemented/supported."
561 "\nIn: {!Q}\n >{!FillC-}^"
562 "," "202,MissingPrecisionValueJS," "Missing precision value after '.' character."
563 "\nIn: {!Q}\n >{!FillC-}^"
564 "," "203,HexadecimalFloatFormatNotSupported," "Hexadecimal float format not implemented/supported."
565 "\nIn: {!Q}\n >{!FillC-}^"
566 "," "204,NoAlternateFormOfConversion," "Alternate form '#' not supported with conversion {!Q}."
567 "\nIn: {!Q}\n >{!FillC-}^"
568 "," "205,NoPrecisionWithConversion," "Precision specification (\".{}\") is not supported with conversion {!Q}."
569 "\nIn: {!Q}\n >{!FillC-}^"
570 "," "206,UnknownDateTimeConversionSuffix," "Unknown date/time conversion suffix {!Q'}."
571 "\nIn: {!Q}\n >{!FillC-}^"
572 "," "207,UnknownConversionJS," "Unknown conversion character {!Q'}."
573 "\nIn: {!Q}\n >{!FillC-}^"
575 "," "501,UnknownPropertyInFormatString," "Unknown property identifier \"{}{}\" in format string.\n"
576 "Format string: {!Q}.\n"
577 "Allowed identifiers:"
578 "," "502,ErrorInResultingFormatString," "Error in resulting format string.\nSource format: {!Q}."
579 "," "510,MissingConfigurationVariable," "Missing or empty configuration variable {!Q} containing user-defined format string."
581 "," "601,UnknownMarker," "Unknown marker at position {}.\n"
582 " Marked text: {!Q}.\n"
584 "," "602,EndmarkerWithoutStart," "Found an end-marker without a start marker at position {}.\n"
585 " Marked text: {!Q}.\n"
593 { variables::Priority::NONE ,
A_CHAR(
"NONE" ) , 1 },
594 { variables::Priority::AutoDetected ,
A_CHAR(
"AutoDetected" ) , 1 },
595 { variables::Priority::DefaultValues ,
A_CHAR(
"DefaultValues") , 1 },
596 { variables::Priority::Standard ,
A_CHAR(
"Standard" ) , 1 },
597 { variables::Priority::ConfigFile ,
A_CHAR(
"ConfigFile" ) , 2 },
598 { variables::Priority::Environment ,
A_CHAR(
"Environment" ) , 1 },
599 { variables::Priority::SessionFile ,
A_CHAR(
"SessionFile" ) , 8 },
600 { variables::Priority::CLI ,
A_CHAR(
"CLI" ) , 2 },
601 { variables::Priority::Session ,
A_CHAR(
"Session" ) , 2 },
602 { variables::Priority::Protected ,
A_CHAR(
"Protected" ) , 1 },
621 { threadmodel::Priority::Lowest ,
A_CHAR(
"Lowest" ), 4 },
622 { threadmodel::Priority::DeferredDeletion,
A_CHAR(
"DeferredDeletion" ), 1 },
623 { threadmodel::Priority::Low ,
A_CHAR(
"Low" ), 1 },
624 { threadmodel::Priority::Standard ,
A_CHAR(
"Standard" ), 1 },
625 { threadmodel::Priority::Highest ,
A_CHAR(
"Highest" ), 5 },
626 { threadmodel::Priority::High ,
A_CHAR(
"High" ), 1 },
639DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK])
640#if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
646DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK])
652 #if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
707 if( targetCamp ==
nullptr )
708 targetCamp=
CAMPS.back();
720DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK2])
721#if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
724DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK2])
730 auto targetCampIt=
CAMPS.rbegin();
731 while(targetCampIt !=
CAMPS.rend() &&
732 *targetCampIt != targetCamp )
736 "Target camp given to function alib::Bootstrap() is not included in list alib::CAMPS.\n"
742 phaseIntegral <=
int( targetPhase ) ;
764 auto& hashMap= lPool->BootstrapGetInternalHashMap();
765 hashMap.BaseLoadFactor( 2.0 );
766 hashMap.MaxLoadFactor ( 5.0 );
775 for(
auto campIt= targetCampIt ; campIt !=
CAMPS.rend() ; ++campIt ) {
776 if ( skipOne ) { skipOne=
false;
continue; }
779 if( (*campIt)->GetResourcePool() !=
nullptr
780 && (*campIt)->GetResourcePool() != actPool )
782 actPool= (*campIt)->GetResourcePool();
786 (*campIt)->BootstrapSetResourcePool( actPool );
795 if ( targetCamp->
GetConfig() ==
nullptr ) {
797 #if ALIB_DEBUG_CRITICAL_SECTIONS
798 targetCamp->
GetConfig()->NodeTable().dcs.DCSName=
"Camp.Config-bootstrap-created";
800 #if !ALIB_SINGLE_THREADED && ALIB_DEBUG
801 targetCamp->
GetConfig().
GetLock().Dbg.Name=
"Camp.Config.Lock-bootstrap-created";
808 for(
auto module= targetCampIt ;
module != CAMPS.rend() ; ++module ) {
809 if ( skipOne ) { skipOne=
false;
continue; }
812 if( (*module)->GetConfig() !=
nullptr && (*module)->GetConfig() != *actConfig)
813 actConfig = &(*module)->GetConfig();
815 (*module)->BootstrapSetConfig( *actConfig );
821 ALIB_DBG(
bool foundThisModuleInList =
false; )
824 if(
int(
camp->GetBootstrapState()) >=
int(actualPhase ) )
830 "With this invocation of Bootstrap() a camp skips a bootstrap phase.\n"
831 "Resource category of the target camp: ",
camp->ResourceCategory )
832 camp->BootstrapSetPhase(actualPhase);
836 if (
camp == targetCamp ) {
837 ALIB_DBG( foundThisModuleInList =
true );
841 "The target camp of function Bootstrap is not included in list alib::CAMPS "
842 "or was already bootstrapped for this phase!\n"
848 #if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
855 #if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
861 "Empty camp list on shutdown. Shutdown invoked twice?" )
862 if( targetCamp ==
nullptr )
863 targetCamp=
CAMPS.front();
868 auto targetCampIt=
CAMPS.begin();
869 while( targetCampIt !=
CAMPS.end()
870 && *targetCampIt != targetCamp )
873 "Target camp given to function alib::Shutdown() is not included in list alib::CAMPS.\n"
877 ALIB_DBG(
bool foundThisModuleInList=
false );
880 ; phaseIntegral<= int( targetPhase )
886 for(
auto campIt=
CAMPS.rbegin() ; campIt !=
CAMPS.rend() ; ++campIt ) {
889 "CAMPS",
"Trying to terminate a not (fully) initialized module. "
893 if (
int(( *campIt )->GetBootstrapState()) > -
int(actualPhase) ) {
896 ALIB_ASSERT_ERROR( (
int(( *campIt )->GetBootstrapState()) == 3 && phaseIntegral == 1 )
897 || (
int(( *campIt )->GetBootstrapState()) == -1 && phaseIntegral == 2 ),
898 "CAMPS",
"With this invocation of Bootstrap(), a camp skips a bootstrap phase \n"
899 "Resource category of the target camp: ", ( *campIt )->ResourceCategory )
902 ( *campIt )->Shutdown(actualPhase );
905 ALIB_DBG(
if(( *campIt ) == targetCamp )
906 foundThisModuleInList=
true; )
909 if(( *campIt ) == targetCamp )
913 "The target camp of function Shutdown is not included in list alib::CAMPS "
914 "or was already shutdown for this phase!\n"
918 #if ALIB_DEBUG_CRITICAL_SECTIONS
921 for(
auto campIt=
CAMPS.rbegin() ; campIt !=
CAMPS.rend() ; ++campIt )
922 (*campIt)->GetConfig()->NodeTable().dcs.DCSLock=
nullptr;
927 for(
auto campIt=
CAMPS.rbegin() ; campIt !=
CAMPS.rend() ; ++campIt ) {
928 ( *campIt )->BootstrapSetResourcePool(
nullptr);
929 ( *campIt )->BootstrapSetConfig(
nullptr);
931 if(( *campIt ) == targetCamp )
936 && targetCamp ==
CAMPS.front() )
@ Huffman
Huffman encoding (byte based).
@ Incremental
Only distances of the values are written.
@ ALL
All compression methods selected.
@ Sparse
Writes '1' if next value is equal to previous, '0' plus next value otherwise.
@ MinMax
Stores the differences between the minimum and maximum value found.
@ VerySparse
Writes the number of following equal or non equal values.
@ NONE
No compression method selected.
NCString ResourceCategory
BootstrapPhases GetBootstrapState()
SharedConfiguration & GetConfig()
SharedPtr< resources::ResourcePool, MonoAllocator > SPResourcePool
void BootstrapSetConfig(const SharedConfiguration &pConfig)
void BootstrapSetResourcePool(const SPResourcePool &pResourcePool)
SPResourcePool & GetResourcePool()
void InsertDerived(TArgs &&... args)
lang::Placeholder< lang::DbgCriticalSections > DbgCriticalSectionsPH
TLock & GetLock() const noexcept
@ Running
The thread's Run method is currently processed.
@ Started
Method Start was invoked but not running, yet.
@ Terminated
The thread is terminated.
#define IF_ALIB_FILES(...)
#define IF_ALIB_BOXING(...)
#define IF_ALIB_THREADS(...)
#define IF_ALIB_ALOX(...)
#define IF_ALIB_SINGLETONS(...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define IF_ALIB_ENUMRECORDS(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define IF_ALIB_EXPRESSIONS(...)
#define ALIB_REL_DBG(releaseCode,...)
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
@ Ascending
Chooses ascending sort oder.
@ Descending
Chooses descending sort oder.
@ Right
Denotes the right side of something.
@ Left
Denotes the left side of something.
@ Copy
Chooses not to clear existing data.
@ Move
Chooses to clear existing data.
@ Global
Denotes global reach.
@ Local
Denotes local reach.
@ No
Denotes non-recursive.
@ Center
Chooses centered alignment.
@ Right
Chooses right alignment.
@ Left
Chooses left alignment.
@ WindowsOS
WindowsOS style line-feeds "\r\n".
@ Platform
Platform specific. Equals to either 'Unix' or 'WindowsOS'.
@ None
No line-feeds, not specified, etc.
@ Unix
Unix-style line-feeds "\n".
@ Remove
Denotes removals.
@ GetCreate
Denotes to create data if not found.
@ Create
Denotes to create data.
@ Insert
Denotes insertions.
@ Get
Denotes to search data.
@ On
Switch it on, switched on, etc.
@ Off
Switch it off, switched off, etc.
@ Begin
The start of a transaction.
@ End
The end of a transaction.
@ Yes
Create if something does not exist.
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
@ Yes
Create default values.
@ Keep
Keep whitespaces in string.
@ Trim
Trim whitespaces away.
@ Enabled
Caching is enabled.
@ Disabled
Caching is disabled.
@ KeepWithSender
Keeps responsibility, e.g., when passing an object.
@ Transfer
Transfers responsibility to the receiving party.
@ Omit
Do not propagate changes.
@ ToDescendants
Propagate changes to descendants/children/subcomponents.
@ Relative
Referring to a relative value.
@ Absolute
Referring to an absolute value.
@ Safe
Do it or treat it with safety.
@ Unsafe
Omit checks or perform unsafe operations.
@ Exclude
Chooses exclusion.
@ Include
Chooses inclusion.
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
ALIB_DLL TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
ALIB_DLL RecursiveLock GLOBAL_ALLOCATOR_LOCK
CompilationFlagMeaningsEntry COMPILATION_FLAG_MEANINGS[40]
format::FormatterJavaStyle FormatterJavaStyle
Type alias in namespace alib.
void AssertALibVersionAndFlags(int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class Basecamp.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
void BootstrapAddDefaultCamps()
ALIB_DLL ListMA< camp::Camp * > CAMPS
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
@ Destruct
The main phase of termination that destructs everything.
lang::integer integer
Type alias in namespace alib.
cli::CliCamp CLI
The singleton instance of ALib Camp class CliCamp.
variables::TSharedConfiguration< SharedLock > SharedConfiguration
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
void Bootstrap(BootstrapPhases targetPhase, camp::Camp *targetCamp, int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
format::Formatter Formatter
Type alias in namespace alib.
lox::ALoxCamp ALOX
The singleton instance of ALib Camp class ALoxCamp.
bool NonCampModulesInitialized
files::FilesCamp FILES
The singleton instance of ALib Camp class FilesCamp.
expressions::ExpressionsCamp EXPRESSIONS
The singleton instance of ALib Camp class ExpressionsCamp.
TCompilationFlags COMPILATION_FLAGS
This is a struct composing an entry in COMPILATION_FLAG_MEANINGS.
unsigned char bits[5]
The Flags.