ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
basecamp.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 ========================================
23
24#include <stack>
25
26//============================================== Module ============================================
27#if ALIB_C20_MODULES
28 /// This is a <em><b>C++ Module</b></em> of the \aliblong.
29 /// Due to the dual-compile option (either as C++20 Modules or using legacy C++ inclusion),
30 /// the C++20 Module names are not of further interest or use.<br>
31 /// In general, the names equal the names of the header files listed in the chapter
32 /// \ref alib_manual_modules_impludes of the \alib User Manual.
33 ///
34 /// @see The documentation of the <em><b>"ALib Module"</b></em> given with the corresponding
35 /// Programmer's Manual \alib_camp.
36 export module ALib.Camp.Base;
37 import ALib.Lang;
38# if ALIB_MONOMEM
39 import ALib.Monomem;
40# endif
41 import ALib.Singletons;
42# if ALIB_STRINGS
43 import ALib.Strings;
44# endif
45# if ALIB_BOXING
46 import ALib.Boxing;
47# endif
48 import ALib.EnumRecords;
49 import ALib.Resources;
50 import ALib.Format;
51 import ALib.Format.StdImplementation;
52 import ALib.System;
53 import ALib.Exceptions;
54 import ALib.Variables;
55 import ALib.Variables.IniFile;
56 import ALib.Camp;
57#else
58# include "ALib.System.H"
59# include "ALib.Exceptions.H"
60# include "ALib.Format.H"
61# include "ALib.Variables.H"
63# include "ALib.Camp.H"
64#endif
65
66//============================================= Exports ============================================
67ALIB_EXPORT namespace alib {
68
69
70//==================================================================================================
71/// This is the reference documentation of module \alib_camp_nl of the \aliblong.<br>
72/// Besides the few entities found and documented here (namely in namespace
73/// <em>%alib::camp</em>), this module <em>"injects"</em> several overloaded versions of
74/// the function \alib{variables;CampVariable} into namespace <em>%alib::variables</em>.
75/// @see
76/// Please also consult the \ref alib_mod_camp "Programmer's Manual" of this module.
77//==================================================================================================
78namespace camp {
79
80
81//##################################################################################################
82// Variables
83//##################################################################################################
84
85/// Configuration variables of \alib.
86/// \note
87/// As required by module \alib_variables, this enumerations is equipped with
88/// \ref alib_enums_records "ALib Enum Records" of type \alib{variables;Declaration}
89/// and resourced with this module.<br>
90/// Hence, all variable categories, names, default values and such can be modified
91/// by modifying the resource data of the singleton of class \alib{camp;Basecamp}.
92enum class Variables
93{
94 LOCALE = 1 , ///< See \ref alibcvALIB_LOCALE.
95 WAIT_FOR_KEY_PRESS = 2 , ///< See \ref alibcvALIB_WAIT_FOR_KEY_PRESS.
96 HAS_CONSOLE_WINDOW = 3 , ///< See \ref alibcvALIB_HAS_CONSOLE_WINDOW.
97};
98
99
100//==================================================================================================
101/// This is a strict singleton class representing module \alib_camp.
102/// The only instance is found with the namespace variable \ref alib::BASECAMP.
103///
104/// @see
105/// For detailed descriptions, please consult the chapter \ref alib_camp_basecamp of the
106/// Programmer's Manual of the module \alib_camp_nl.
107//==================================================================================================
108class Basecamp : public Camp
109{
110 public:
111 /// If \c true, within #Shutdown, it is waited for a key press in the console
112 /// window.<br>
113 /// By default, this flag is enabled when debugging a console application under Visual
114 /// Studio.<br>
115 /// This default behavior can be overruled by setting configuration variable
116 /// \ref alibcvALIB_WAIT_FOR_KEY_PRESS.<br>
117 /// In addition, this public flag may be modified at run-time (after method #Bootstrap was
118 /// invoked).
120
121 /// This flag indicates if the current process has console output window attached.
122 /// While this is not detectable in Unix like systems (or just with huge efforts), in
123 /// windows it is. The determination is performed in #Bootstrap and done as follows
124 /// - If configuration variable \b ALIB_HAS_CONSOLE_WINDOW
125 /// is set, its value is returned.
126 /// - Otherwise, on Unix like OS\c true is returned.
127 /// - On Windows OS it is determined if a console window is attached to the process
128 /// using system call \e GetConsoleWindow() and compare its result to \e NULL.
129 ///
130 /// In addition, this public flag may be modified at run-time (after method #Bootstrap was
131 /// invoked).
132 ///
133 /// \note
134 /// The evaluation of configuration variable \b ALIB_HAS_CONSOLE_WINDOW is done
135 /// only if module \alib_variables is included in the \alibbuild.
137
138 /// This string is set during bootstrapping in the case that a locale information was
139 /// found (via standard environment variables or \alib variable \alib{camp::Variables;LOCALE})
140 /// and successfully set.<br>
141 /// Otherwise this string is \e nulled.
143
144 /// Constructor.<br>
145 /// While this is public, it must not be invoked as this is a strict singleton type.
146 /// (See notes in \ref alib_camp_camp).
148 Basecamp();
149
150 /// Implementation of \alib{camp;Camp::Bootstrap}.
151 ///
152 /// In phase \alib{BootstrapPhases::Final} performs:
153 /// - In glibc versions of \alib (GNU/unix) probably invoke glibc method
154 /// <em>setlocale()</em>, depending on the setting of the environment variables
155 /// <em>LANG</em> and <em>LANGUAGE</em> and depending on \alib configuration variable
156 /// \ref alibcvALIB_LOCALE.
157 ///
158 /// In addition, invokes
159 /// \alib{strings;TNumberFormat::SetFromLocale;NumberFormat::SetFromLocale} on static singleton
160 /// \alib{strings;TNumberFormat::Global;NumberFormat::Global}.
161 ///
162 /// - Config variable \ref WAIT_FOR_KEY_PRESS is read and field
163 /// #WaitForKeyPressOnTermination set accordingly.
165 virtual void Bootstrap() override;
166
167 /// Terminates this camp.
168 /// @param phase The shutdown phase to perform.
170 virtual void Shutdown( ShutdownPhases phase) override;
171
172 //################################################################################################
173 // Environment definition/detection
174 //################################################################################################
175 /// If \c true, the current process is under the hood of a debugger.
176 ///
177 /// @return \c true if the application is run in a debugger.
179 bool IsDebuggerPresent();
180
181}; // class Basecamp
182
183} // namespace alib[::camp]
184
185/// The singleton instance of \alibcamp class \alib{camp;Basecamp}.
187
188} // namespace [alib]
189
190
191
193ALIB_RESOURCED_IN_MODULE( alib::format::ByteSizeUnits , alib::BASECAMP, "BS" )
194ALIB_RESOURCED_IN_MODULE( alib::format::FMTExceptions , alib::BASECAMP, "FE" )
195
196ALIB_RESOURCED_IN_MODULE( alib::variables::Exceptions , alib::BASECAMP, "VARE" )
197
198DOX_MARKER([DOX_VARIABLES_DECLARATION5])
199ALIB_ENUMS_ASSIGN_RECORD( alib::camp::Variables, alib::variables::Declaration )
200ALIB_RESOURCED_IN_MODULE( alib::camp::Variables, alib::BASECAMP, "Var" )
201DOX_MARKER([DOX_VARIABLES_DECLARATION5])
202ALIB_RESOURCED_IN_MODULE( alib::variables::Priority , alib::BASECAMP, "VarPrio" )
ALIB_DLL bool IsDebuggerPresent()
Definition basecamp.cpp:907
bool WaitForKeyPressOnTermination
Definition basecamp.mpp:119
virtual ALIB_DLL void Bootstrap() override
Definition basecamp.cpp:96
ALIB_DLL Basecamp()
Definition basecamp.cpp:87
Camp(const NCString &resourceCategory)
Definition camp.inl:120
#define ALIB_DLL
Definition alib.inl:503
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
#define ALIB_EXPORT
Definition alib.inl:497
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
@ HAS_CONSOLE_WINDOW
See ALIB/HAS_CONSOLE_WINDOW.
Definition basecamp.mpp:96
@ LOCALE
See ALIB/LOCALE.
Definition basecamp.mpp:94
@ WAIT_FOR_KEY_PRESS
See ALIB/WAIT_FOR_KEY_PRESS.
Definition basecamp.mpp:95
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class Basecamp.
Definition basecamp.cpp:81
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition camp.inl:42
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189
ALIB_DLL void Shutdown()