ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
aloxmodule.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_alox 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_ALOXMODULE
9#define HPP_ALIB_ALOXMODULE 1
10
11#if !defined (HPP_ALIB_ALOX)
12# include "alib/alox/alox.hpp"
13#endif
14
16
17#if !defined (HPP_ALOX_DETAIL_TEXTLOGGER_TEXTLOGGER)
19#endif
20
21#if !defined (HPP_ALIB_LANG_CAMP)
23#endif
24
25#if !defined(HPP_ALIB_CONFIG_CONFIG)
26# include "alib/config/config.hpp"
27#endif
28
29#if !defined(HPP_ALIB_CONFIG_CONFIGURATION)
31#endif
32
33namespace alib { namespace lox {
34
35/** ************************************************************************************************
36 * Configuration variables uses by ALox.
37 * \note
38 * As required by module \alib_config, this enumerations is equipped with
39 * \ref alib_enums_records "ALib Enum Records" of type \alib{config;VariableDecl} and resourced
40 * with this module \alib_alox_nl.<br>
41 * Hence, all variable categories, names, default values and such can be modified
42 * by modifying the resource data of the singleton of class \alib{lang::basecamp;BaseCamp}.
43 **************************************************************************************************/
44enum class Variables
45{
46 /** Denotes configuration variable \ref alxcvALOX_NO_IDE_LOGGER used by \alox{Log::AddDebugLogger}. */
47 NO_IDE_LOGGER = 1,
48
49 /** Denotes configuration variable \ref alxcvALOX_CONSOLE_TYPE used by \alox{Lox::CreateConsoleLogger}. */
50 CONSOLE_TYPE = 2,
51
52 /** Denotes configuration variable \ref alxcvALOX_LOXNAME_LOGGERNAME_VERBOSITY. */
53 VERBOSITY = 3,
54
55 /** Denotes configuration variable \ref alxcvALOX_GLOBAL_SOURCE_PATH_TRIM_RULES. */
56 SPTR_GLOBAL = 4,
57
58 /** Denotes configuration variable \ref alxcvALOX_LOXNAME_SOURCE_PATH_TRIM_RULES used by class \alox{Lox}. */
59 SPTR_LOX = 5,
60
61 /** Denotes configuration variable \ref alxcvALOX_LOXNAME_DOMAIN_SUBSTITUTION used by class \alox{Lox}. */
63
64 /** Denotes configuration variable \ref alxcvALOX_LOXNAME_PREFIXES used by class \alox{Lox}. */
65 PREFIXES = 7,
66
67 /** Denotes configuration variable \ref alxcvALOX_LOXNAME_DUMP_STATE_ON_EXIT used by class \alox{Lox}. */
69
70 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_AUTO_SIZES used by class \alox{detail::textlogger,TextLogger}. */
71 AUTO_SIZES = 20,
72
73 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_FORMAT used by class \alox{detail::textlogger,TextLogger}. */
74 FORMAT = 21,
75
76 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_FORMAT_DATE_TIME used by class \alox{detail::textlogger,TextLogger}. */
78
79 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_FORMAT_MULTILINE used by class \alox{detail::textlogger,TextLogger}. */
81
82 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_FORMAT_TIME_DIFF used by class \alox{detail::textlogger,TextLogger}. */
84
85 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_MAX_ELAPSED_TIME used by class \alox{detail::textlogger,TextLogger}. */
87
88 /** Denotes configuration variable \ref alxcvALOX_LOGGERNAME_REPLACEMENTS used by class \alox{detail::textlogger,TextLogger}. */
89 REPLACEMENTS = 26,
90
91 /** Denotes configuration variable \ref alxcvALOX_CONSOLE_LIGHT_COLORS used by colorful specializations of class \alox{detail::textlogger,TextLogger}. */
93
94 #if defined(_WIN32)
95 /** Denotes configuration variable \ref alxcvALOX_CODE_PAGE used by class \alox{loggers,WindowsConsoleLogger}. */
96 CODEPAGE = 28,
97 #endif
98};
99
100/** ************************************************************************************************
101 * This is the module class for \alox logging library residing in namespace \ref alib::lox.
102 *
103 * This is a strict singleton class. The only instance is found with namespace variable
104 * \ref alib::ALOX.
105 **************************************************************************************************/
106class ALox : public lang::Camp
107{
108 public:
109 /** ****************************************************************************************
110 * Constructor.<br>
111 * While this is public, it must not be invoked as this is a strict singleton type.
112 * (See notes in \ref alib_manual_camp_modules_campmodule).
113 ******************************************************************************************/
114 ALox();
115
116 // #############################################################################################
117 // Public fields
118 // #############################################################################################
119 public:
120
121 #if defined(_WIN32)
122 /** Attributes of corresponding configuration variable \ref alxcvALOX_CODE_PAGE
123 * used by class \alox{loggers,WindowsConsoleLogger}. */
125 #endif
126
127 // #############################################################################################
128 // Protected fields
129 // #############################################################################################
130 protected:
131
132 // #############################################################################################
133 // Lox management
134 // #############################################################################################
135 public:
136 /** ****************************************************************************************
137 * Returns a \b %Lox with the given name.
138 * A \b %Lox is only found if it was created and registered with \alox using #Register.
139 * If not found, and parameter \p{create} is \c true (the default), a new \b Lox is created,
140 * registered and returned.
141 *
142 * @param name The name of the \b %Lox to search and optionally to create.
143 * Comparison is case insensitive.
144 * @param create Denotes whether a \b %Lox that was not found is created.
145 * Optional and defaults to \b %CreateIfNotExists::No.
146 * @return The \b Lox found, \c nullptr in case of failure.
147 ******************************************************************************************/
148 ALIB_API Lox* Get( const NString& name,
150
151 /** ****************************************************************************************
152 * Registers or un-registers a \b %Lox object statically with \alox.
153 * Once registered, any code entity of the same process is enabled to retrieve
154 * the \b %Lox using #Get.<br>
155 * No two objects with the same name must be registered. If this is done, the latter
156 * will not be registered and not be found by #Get. In debug-compilations, an \alib
157 * error report is written (by default raises 'assert') if a name is registered twice.<br>
158 * Note that name comparison is performed case <b>in</b>-sensitive.
159 *
160 * If debug-logging is enabled (depends on optional compiler symbols) and used, the
161 * singleton of type \% Lox provided for debug-logging is registered. This uses the name
162 * \c "Log".
163 *
164 * Registration is \e not mandatory but done by default by the constructor of class \b %Lox.
165 * Therefore, to keep a \b Lox private, an optional parameter is available.
166 *
167 * @param lox The \b %Lox to register.
168 * @param operation If \b %ContainerOp::Remove, the given \p{Lox} is deregistered.
169 * Defaults to \b %ContainerOp::Insert.
170 ******************************************************************************************/
171 ALIB_API void Register( Lox* lox, lang::ContainerOp operation );
172
173 /** ****************************************************************************************
174 * Resets this object. Concretely the following steps are performed:
175 * - If the debug lox singleton exists, it is deleted.
176 * - It is asserted that no other lox object is registered
177 * - The ALOX section of the configuration plugins are deleted
178 * - It is asserted that not more than 4 plugins are in the configuration
179 *
180 * \attention
181 * This method was introduced to support resetting \alox in the unit tests.
182 * In real applications, this method should NOT be used.
183 * Side effects might appear using this method and it is not tested otherwise than
184 * used in tests!
185 ******************************************************************************************/
186 ALIB_API void Reset();
187
188 // #############################################################################################
189 // Internals
190 // #############################################################################################
191 protected:
192 /** ****************************************************************************************
193 * Implementation of \alib{lang;Camp::bootstrap}.
194 *
195 * In phase \alib{BootstrapPhases::Final} performs:
196 * - Adds box-function \alib{boxing;FAppend::Appendable} for type
197 * \alox{detail,Logger}.
198 * @param phase The initialization phase to perform.
199 ******************************************************************************************/
200 virtual void bootstrap( BootstrapPhases phase ) override;
201
202 /** ****************************************************************************************
203 * Terminates this module.
204 * @param phase The shutdown phase to perform.
205 ******************************************************************************************/
206 virtual void shutdown( ShutdownPhases phase ) override;
207
208};// class ALox
209
210} // namespace alib[::lox]
211
212/** The singleton instance of \alibcamp class \alib{lox;ALox}. */
213extern ALIB_API lox::ALox ALOX;
214
215
216/// Type alias in namespace \b alib.
218
219} // namespace [alib]
220
223
224// #################################################################################################
225// T_Append<Scope> / T_Append<Verbosity>
226// #################################################################################################
227#if !defined(ALIB_DOX)
228namespace alib::strings {
229
230template<> struct T_Append<Scope,nchar>
231{
233 void operator()( TAString<nchar>& target, const Scope src );
234};
235
236template<> struct T_Append<std::pair<Verbosity, Priorities>,nchar>
237{
239 void operator()( TAString<nchar>& target, const std::pair<Verbosity, Priorities>& src );
240};
241
242} // namespace [alib::strings]
243#endif // !defined(ALIB_DOX)
244
245#endif // HPP_ALIB_ALOXMODULE
ALIB_API void Reset()
virtual void bootstrap(BootstrapPhases phase) override
virtual void shutdown(ShutdownPhases phase) override
ALIB_API void Register(Lox *lox, lang::ContainerOp operation)
ALIB_API Lox * Get(const NString &name, lang::CreateIfNotExists create=lang::CreateIfNotExists::No)
static ALIB_API config::VariableDecl CODEPAGE
#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_RESOURCED_IN_MODULE(T, Camp, ResName)
Definition alib.cpp:57
ShutdownPhases
Definition camp.hpp:35
BootstrapPhases
Definition camp.hpp:26
lox::Scope Scope
Type alias in namespace alib.
lox::ALox ALOX
characters::nchar nchar
Type alias in namespace alib.
void operator()(TAString< TChar > &target, const TAppendable &src)