ALib C++ Library
Library Version: 2412 R0
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#pragma once
12
14
15#include "alib/lang/basecamp/camp.hpp"
16#if ALIB_CONFIGURATION
18#endif
19
20
21namespace alib { namespace lang {
22
23namespace system{ class CalendarDateTime; }
24
25//==================================================================================================
26/// This is the reference documentation of module \alib_basecamp_nl of the \aliblong.<br>
27/// Besides the few entities found and documented here (namely in namespace
28/// <em>%alib::lang::basecamp</em>), this module <b>"injects"</b> the following entities to different
29/// places:
30///
31/// Into namespace <b>%alib</b>:
32/// - enum class \ref alib::BootstrapPhases
33/// - enum class \ref alib::ShutdownPhases
34/// - overload function \ref alib::Bootstrap( BootstrapPhases\, lang::Camp*\, int\, int\, uint64_t );
35/// - overload function \ref alib::Shutdown( ShutdownPhases \, lang::Camp*);
36///
37/// Into namespace <b>%alib::lang</b>
38/// - class \ref alib::lang::Camp
39/// - class \ref alib::lang::Exception
40/// - class \ref alib::lang::Report
41/// - class \ref alib::lang::ReportWriter
42///
43/// - namespace <b>%alib::lang::basecamp</b> (this one)
44/// - namespace \ref alib::lang::format
45/// - namespace \ref alib::lang::resources
46/// - namespace \ref alib::lang::system
47///
48///
49///
50/// \note
51/// This constitutes an explicit exception to the general \alib rules: All other
52/// \alibmods reside in their own, dedicated single namespace (of course optionally with sub-namespaces)
53/// within namespace \ref alib. The justification and explanation for this is given with
54/// chapter \ref alib_manual_camp_modules "3. ALib Camps and special Module BootCamp" of the
55/// Programmer's Manual of \alib.
56///
57/// @see
58/// Please also consult the \ref alib_mod_basecamp "Programmer's Manual" of this module.
59//==================================================================================================
60namespace basecamp {
61
62
63// #################################################################################################
64// Variables
65// #################################################################################################
66#if ALIB_CONFIGURATION
67 /// Configuration variables of \alib.
68 /// \note
69 /// As required by module \alib_config, this enumerations is equipped with
70 /// \ref alib_enums_records "ALib Enum Records" of type \alib{config;Declaration}
71 /// and resourced with this module.<br>
72 /// Hence, all variable categories, names, default values and such can be modified
73 /// by modifying the resource data of the singleton of class \alib{lang::basecamp;BaseCamp}.
74 enum class Variables
75 {
76 LOCALE = 1 , ///< See \ref alibcvALIB_LOCALE.
77 WAIT_FOR_KEY_PRESS = 2 , ///< See \ref alibcvALIB_WAIT_FOR_KEY_PRESS.
78 HAS_CONSOLE_WINDOW = 3 , ///< See \ref alibcvALIB_HAS_CONSOLE_WINDOW.
79 };
80#endif // ALIB_CONFIGURATION
81
82
83
84//==================================================================================================
85/// This is a strict singleton class representing module \alib_basecamp.
86/// The only instance is found with namespace variable \ref alib::BASECAMP.
87///
88/// @see
89/// For detailed descriptions, please consult
90/// - Chapter \ref alib_manual_camp_modules "3. ALib Camps and special Module BootCamp", as well as
91/// - this camps' \ref alib_mod_basecamp "Programmer's Manual".
92///
93/// ## Friends ##
94/// class \alib{lang::system;CalendarDateTime}
95//==================================================================================================
96class BaseCamp : public lang::Camp
97{
98 #if !DOXYGEN
100 #endif
101
102 public:
103 /// If \c true, within #Shutdown, it is waited for a key press in the console
104 /// window.<br>
105 /// By default, this flag is enabled when debugging a console application under Visual
106 /// Studio.<br>
107 /// This default behavior can be overruled by setting configuration variable
108 /// \ref alibcvALIB_WAIT_FOR_KEY_PRESS.<br>
109 /// In addition, this public flag may be modified at run-time (after method #Bootstrap was
110 /// invoked).
112
113 /// This flag indicates if the current process has console output window attached.
114 /// While this is not detectable in Unix like systems (or just with huge efforts), in
115 /// windows it is. The determination is performed in #bootstrap and done as follows
116 /// - If configuration variable \b ALIB_HAS_CONSOLE_WINDOW
117 /// is set, its value is returned.
118 /// - Otherwise, on Unix like OS\c true is returned.
119 /// - On Windows OS it is determined if a console window is attached to the process
120 /// using system call \e GetConsoleWindow() and compare its result to \e NULL.
121 ///
122 /// In addition, this public flag may be modified at run-time (after method #Bootstrap was
123 /// invoked).
124 ///
125 /// \note
126 /// The evaluation of configuration variable \b ALIB_HAS_CONSOLE_WINDOW is done
127 /// only if module \alib_config is included in the \alibdist.
129
130 /// This string is set during bootstrapping in the case that a locale information was
131 /// found (via standard environment variables or \alib variable \alib{lang::basecamp::Variables;LOCALE})
132 /// and successfully set.<br>
133 /// Otherwise this string is \e nulled.
135
136 //=========================================================================================
137 /// Constructor.<br>
138 /// While this is public, it must not be invoked as this is a strict singleton type.
139 /// (See notes in \ref alib_manual_camp_modules_campmodule).
140 //=========================================================================================
142 BaseCamp();
143
144 protected:
145 //==========================================================================================
146 /// Implementation of \alib{lang;Camp::bootstrap}.
147 ///
148 /// In phase \alib{BootstrapPhases::Final} performs:
149 /// - In glibc versions of \alib (GNU/unix) probably invoke glibc method
150 /// <em>setlocale()</em>, depending on the setting of the environment variables
151 /// <em>LANG</em> and <em>LANGUAGE</em> and depending on \alib configuration variable
152 /// \ref alibcvALIB_LOCALE.
153 ///
154 /// In addition, invokes
155 /// \alib{strings;TNumberFormat::SetFromLocale;NumberFormat::SetFromLocale} on static singleton
156 /// \alib{strings;TNumberFormat::Global;NumberFormat::Global}.
157 ///
158 /// - Config variable \ref WAIT_FOR_KEY_PRESS is read and field
159 /// #WaitForKeyPressOnTermination set accordingly.
160 ///
161 /// @param phase The initialization phase to perform.
162 //==========================================================================================
164 virtual void bootstrap( BootstrapPhases phase ) override;
165
166 //==========================================================================================
167 /// Terminates this camp.
168 /// @param phase The shutdown phase to perform.
169 //==========================================================================================
171 virtual void shutdown( ShutdownPhases phase) override;
172
173 // #############################################################################################
174 // Environment definition/detection
175 // #############################################################################################
176 public:
177 //==========================================================================================
178 /// If \c true, the current process is under the hood of a debugger.
179 ///
180 /// @return \c true if the application is run in a debugger.
181 //==========================================================================================
183 bool IsDebuggerPresent();
184
185
186}; // class BaseCamp
187
188}} // namespace alib[::lang::basecamp]
189
190/// The singleton instance of \alibcamp class \alib{lang::basecamp;BaseCamp}.
192
193} // namespace [alib]
194
198
199ALIB_BOXING_VTABLE_DECLARE( alib::lang::system::SystemErrors , vt_system_systemerrors )
200ALIB_ENUMS_ASSIGN_RECORD( alib::lang::system::SystemErrors , alib::lang::ERException )
201ALIB_RESOURCED_IN_MODULE( alib::lang::system::SystemErrors , alib::BASECAMP, "SE" )
202
203#if ALIB_CONFIGURATION
204DOX_MARKER([DOX_CONFIG_DECLARATION5])
207DOX_MARKER([DOX_CONFIG_DECLARATION5])
208#endif
209
210
211
212#endif // HPP_ALIB_LANG_BASECAMP
213
virtual ALIB_API void bootstrap(BootstrapPhases phase) override
Definition basecamp.cpp:163
virtual ALIB_API void shutdown(ShutdownPhases phase) override
ALIB_API bool IsDebuggerPresent()
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Definition records.hpp:712
#define ALIB_API
Definition alib.hpp:639
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
Definition vtable.inl:460
#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.
SystemExceptions
Denotes exceptions thrown by classes of namespace alib::lang::system.
SystemErrors
Denotes result values returned by system functions (glibc, etc).
Definition alib.cpp:69
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition alib.hpp:1418
lang::basecamp::BaseCamp BASECAMP
The singleton instance of ALib Camp class BaseCamp.
Definition basecamp.cpp:70
BootstrapPhases
Initialization levels usable with Bootstrapping ALib Camps.
Definition alib.hpp:1393
lang::system::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
Definition calendar.hpp:743