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