ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
basecamp.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_basecamp of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_ALIB_LANG_BASECAMP
9#define HPP_ALIB_LANG_BASECAMP 1
10
11#if !defined(HPP_ALIB_CAMP_ERRORS)
13#endif
14
16
17#if !defined(HPP_ALIB_LANG_CAMP)
19#endif
20
21#if ALIB_CONFIGURATION && !defined(HPP_ALIB_CONFIG_VARIABLEDECL)
23#endif
24
25
26namespace alib { namespace lang {
27
28namespace system{ class CalendarDateTime; }
29
30/** ************************************************************************************************
31 * This is the reference documentation of module \alib_basecamp_nl of the \aliblong.<br>
32 * Besides the few entities found and documented here (namely in namespace
33 * <em>%alib::lang::basecamp</em>), this module <b>"injects"</b> the following entities to different
34 * places:
35 *
36 * Into namespace <b>%alib</b>:
37 * - enum class \ref alib::BootstrapPhases
38 * - enum class \ref alib::ShutdownPhases
39 * - overload function \ref alib::Bootstrap( BootstrapPhases\, lang::Camp*\, int\, int\, uint64_t );
40 * - overload function \ref alib::Shutdown( ShutdownPhases \, lang::Camp*);
41 *
42 * Into namespace <b>%alib::lang</b>
43 * - class \ref alib::lang::Camp
44 * - class \ref alib::lang::Exception
45 * - class \ref alib::lang::Report
46 * - class \ref alib::lang::ReportWriter
47 *
48 * - namespace <b>%alib::lang::basecamp</b> (this one)
49 * - namespace \ref alib::lang::format
50 * - namespace \ref alib::lang::resources
51 * - namespace \ref alib::lang::system
52 *
53 *
54 *
55 * \note
56 * This constitutes an explicit exclamation from the general \alib rules: All other
57 * \alibmods reside in their own, dedicated single namespace (of-course optionally with sub-namespaces)
58 * within namespace \ref alib. The justification and explanation for this is given with
59 * chapter \ref alib_manual_camp_modules "3. ALib Camps and special Module BootCamp" of the
60 * Programmer's Manual of \alib.
61 *
62 * @see
63 * Please also consult the \ref alib_mod_basecamp "Programmer's Manual" of this module.
64 **************************************************************************************************/
65namespace basecamp {
66
67
68// #################################################################################################
69// Variables
70// #################################################################################################
71#if ALIB_CONFIGURATION
72 /**
73 * Configuration variables of \alib.
74 * \note
75 * As required by module \alib_config, this enumerations is equipped with
76 * \ref alib_enums_records "ALib Enum Records" of type \alib{config;VariableDecl}
77 * and resourced with this module.<br>
78 * Hence, all variable categories, names, default values and such can be modified
79 * by modifying the resource data of the singleton of class \alib{lang::basecamp;BaseCamp}.
80 */
81 enum class Variables
82 {
83 LOCALE = 1 , ///< See \ref alibcvALIB_LOCALE.
84 WAIT_FOR_KEY_PRESS = 2 , ///< See \ref alibcvALIB_WAIT_FOR_KEY_PRESS.
85 HAS_CONSOLE_WINDOW = 3 , ///< See \ref alibcvALIB_HAS_CONSOLE_WINDOW.
86 };
87#endif // ALIB_CONFIGURATION
88
89
90
91/** ************************************************************************************************
92 * This is a strict singleton class representing module \alib_basecamp.
93 * The only instance is found with namespace variable \ref alib::BASECAMP.
94 *
95 * @see
96 * For detailed descriptions, please consult
97 * - Chapter \ref alib_manual_camp_modules "3. ALib Camps and special Module BootCamp", as well as
98 * - this camps' \ref alib_mod_basecamp "Programmer's Manual".
99 *
100 * ## Friends ##
101 * class \alib{lang::system;CalendarDateTime}
102 **************************************************************************************************/
103class BaseCamp : public lang::Camp
104{
105 #if !defined(ALIB_DOX)
107 #endif
108
109 public:
110 /**
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).
119 */
121
122 /**
123 * This flag indicates if the current process has console output window attached.
124 * While this is not detectable in Unix like systems (or just with huge efforts), in
125 * windows it is. The determination is performed in #bootstrap and done as follows
126 * - If configuration variable \b ALIB_HAS_CONSOLE_WINDOW
127 * is set, its value is returned.
128 * - Otherwise, on Unix like OS\c true is returned.
129 * - On Windows OS it is determined if a console window is attached to the process
130 * using system call \e GetConsoleWindow() and compare its result to \e NULL.
131 *
132 * In addition, this public flag may be modified at run-time (after method #Bootstrap was
133 * invoked).
134 *
135 * \note
136 * The evaluation of configuration variable \b ALIB_HAS_CONSOLE_WINDOW is done
137 * only if module \alib_config is included in the \alibdist.
138 */
140
141 /**
142 * This string is set during bootstrapping in the case that a locale information was
143 * found (via standard environment variables or \alib variable \alib{lang::basecamp::Variables;LOCALE})
144 * and successfully set.<br>
145 * Otherwise this string is \e nulled.
146 */
148
149 /** ****************************************************************************************
150 * Constructor.<br>
151 * While this is public, it must not be invoked as this is a strict singleton type.
152 * (See notes in \ref alib_manual_camp_modules_campmodule).
153 ******************************************************************************************/
155 BaseCamp();
156
157 protected:
158 /** ****************************************************************************************
159 * Implementation of \alib{lang;Camp::bootstrap}.
160 *
161 * In phase \alib{BootstrapPhases::Final} performs:
162 * - In glibc versions of \alib (GNU/unix) probably invoke glibc method
163 * <em>setlocale()</em>, depending on the setting of the environment variables
164 * <em>LANG</em> and <em>LANGUAGE</em> and depending on \alib configuration variable
165 * \ref alibcvALIB_LOCALE.
166 *
167 * In addition, invokes
168 * \alib{strings;TNumberFormat::SetFromLocale;NumberFormat::SetFromLocale} on static singleton
169 * \alib{strings;TNumberFormat::Global;NumberFormat::Global}.
170 *
171 * - Config variable \ref WAIT_FOR_KEY_PRESS is read and field
172 * #WaitForKeyPressOnTermination set accordingly.
173 *
174 * @param phase The initialization phase to perform.
175 ******************************************************************************************/
177 virtual void bootstrap( BootstrapPhases phase ) override;
178
179 /** ****************************************************************************************
180 * Terminates this module. (Nothing to do.)
181 * @param phase The shutdown phase to perform.
182 ******************************************************************************************/
184 virtual void shutdown( ShutdownPhases phase) override;
185
186 // #############################################################################################
187 // Environment definition/detection
188 // #############################################################################################
189 public:
190 /** ************************************************************************************
191 * If \c true, the current process is under the hood of a debugger.
192 *
193 * @return \c true if the application is run in a debugger.
194 **************************************************************************************/
196 bool IsDebuggerPresent();
197
198
199}; // class BaseCamp
200
201}} // namespace alib[::lang::basecamp]
202
203/** The singleton instance of \alibcamp class \alib{lang::basecamp;BaseCamp}. */
205
206} // namespace [alib]
207
211
212ALIB_BOXING_VTABLE_DECLARE( alib::lang::system::SystemErrors , vt_system_systemerrors )
213ALIB_ENUMS_ASSIGN_RECORD( alib::lang::system::SystemErrors , alib::lang::ERException )
214ALIB_RESOURCED_IN_MODULE( alib::lang::system::SystemErrors , alib::BASECAMP, "SE" )
215
216#if ALIB_CONFIGURATION
219#endif
220
221
222
223#endif // HPP_ALIB_LANG_BASECAMP
virtual ALIB_API void bootstrap(BootstrapPhases phase) override
Definition basecamp.cpp:240
virtual ALIB_API void shutdown(ShutdownPhases phase) override
ALIB_API bool IsDebuggerPresent()
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:190
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Definition records.hpp:752
#define ALIB_API
Definition alib.hpp:538
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
Definition vtable.inl:477
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
@ HAS_CONSOLE_WINDOW
See ALIB_HAS_CONSOLE_WINDOW.
@ WAIT_FOR_KEY_PRESS
See ALIB_WAIT_FOR_KEY_PRESS.
Definition alib.cpp:57
ShutdownPhases
Definition camp.hpp:35
lang::basecamp::BaseCamp BASECAMP
Definition basecamp.cpp:136
BootstrapPhases
Definition camp.hpp:26
lang::system::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
Definition calendar.hpp:753