ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
variables.prepro.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8#ifndef HPP_ALIB_VARIABLES_PP
9#define HPP_ALIB_VARIABLES_PP
10#pragma once
11#ifndef HPP_ALIB
12# include "alib/alib.prepro.hpp"
13#endif
14#if ALIB_VARIABLES
15
16//##################################################################################################
17// Enum Priority.
18// Note: This is excluded from the module because it is used by ALox and if it was included, ALox
19// needed to include Configuration in is base module already.
20//##################################################################################################
21namespace alib { namespace variables {
22
23
24//==================================================================================================
25/// #"ArithmeticalTraits;Arithmetical enumeration" used to control write access to
26/// configuration variables, depending on the source of assignable values.
27/// @see Chapter #"alib_variables_definition_prios" of the Programmer's Manual of camp
28/// \alib_variables_nl.
29//==================================================================================================
30enum class Priority : uint16_t {
31 /// This priority value denotes that a variable is undefined and has no value set.
32 /// The underlying integral value is \c 0.
33 NONE = 0,
34
35 /// Constant providing a priority which is even lower than default. A use-case for this
36 /// priority are for third party libraries that may preset variables in cases where values are
37 /// estimated or detected instead of defaulted.<br>
38 /// A using code of such library may then overwrite the auto-detection estimates, by setting a
39 /// default value in the configuration.<br>
40 /// This priority is not used internally (by any \alib camp) today.<br>
41 /// The underlying integral value is \c 1,000.
43
44 /// Used to store default values, either from (resourced) declarations, hard-coded values,
45 /// or values provided with the method
46 /// #"Configuration::PresetImportString(StringEscaper*);Configuration::PresetImportString".
47 /// The underlying integral value is \c 2,000.
49
50 /// This is the default priority when a variable is defined for setting a 'hard-coded' value.
51 /// The underlying integral value is \c 4,000. Hard-coded values have a higher priority
52 /// than default values, but are deemed to get overwritten by any other configuration source.
53 Standard = 4000,
54
55 /// External application configuration sources use this element to define variables
56 /// found. This element is also used with built-in class #"IniFileFeeder".
57 /// The underlying integral value is \c 6,000.
58 ConfigFile = 6000,
59
60 /// Used with plug-in #"EnvironmentVariablesPlugin".
61 /// The underlying integral value is \c 8,000.
63
64 /// Used to store temporary session information. Those are higher than #"%Environment" but lower
65 /// than #"%CLI". This session priority is only a proposal. Implementations might use a
66 /// different value, even for different variables, for example, <b>Environment - 1 </b> or
67 /// <b>CLI + 1 </b>. It depends on the use case.<br>
68 /// The underlying integral value is \c 10,000.
69 SessionFile = 10000,
70
71 /// Used with plug-in #"CLIVariablesPlugin".
72 /// The underlying integral value is \c 12,000.
73 CLI = 12000,
74
75 /// Used to store generate temporary session information. While usually changes made in
76 /// source code has a low priority, session information is overwritten by running software, no
77 /// matter from which external source an existing values came.
78 /// If software wants to disallow the change of session information imposed by a library
79 /// or a different software part, still a value can be set to protected.
80 /// The underlying integral value is \c 14,000.
81 Session = 14000,
82
83 /// Used to define variables with protected values. If all code entities apply to the
84 /// #"alib_variables_definition;contract that this camp imposes" in respect to variable
85 /// definitions and priorities, a value set with this priority cannot be manipulated from
86 /// "outside", hence by config files, command-line arguments or any custom configuration source
87 /// or plug-in.
88 ///
89 /// The underlying integral value is <c>std::numeric_limits<int>::max()</c>.
90 Protected = (std::numeric_limits<uint16_t>::max)(),
91
92};
93
94} // namespace alib::[config]
95
96/// Type alias in namespace #"%alib".
98
99} // namespace [alib]
100
101//##################################################################################################
102// Macro introduced by module ALib.Variables
103//##################################################################################################
104#define ALIB_VARIABLES_DEFINE_TYPE( Namespace, CPPName,CfgTypeString) \
105ALIB_EXPORT namespace alib::variables::detail { \
106struct VMeta_ ## CPPName : public VMeta \
107{ \
108 ALIB_DLL String typeName () const override { return CfgTypeString; } \
109ALIB_DBG(ALIB_DLL const std::type_info& dbgTypeID() override { return typeid(Namespace CPPName); } ) \
110 ALIB_DLL void construct(VDATA* obj, PoolAllocator&) override { new (obj) Namespace CPPName(); } \
111 ALIB_DLL void destruct (VDATA* obj, PoolAllocator&) override { reinterpret_cast<Namespace CPPName*>(obj)->~CPPName(); } \
112 ALIB_DLL size_t size () override { static_assert(alignof(Namespace CPPName) <= alib::PoolAllocator::MAX_ALIGNMENT); return (std::max)( sizeof(Namespace CPPName), sizeof(void*) ); } \
113 ALIB_DLL void imPort (VDATA*, Configuration&, const StringEscaper&, const String&) override;\
114 ALIB_DLL void exPort (VDATA*, Configuration&, const StringEscaper&, AString&) override;\
115};}
116
117#define ALIB_VARIABLES_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( Namespace, CPPName,CfgTypeString) \
118ALIB_EXPORT namespace alib::variables::detail { \
119struct VMeta_ ## CPPName : public VMeta \
120{ \
121 ALIB_DLL String typeName () const override { return CfgTypeString; } \
122ALIB_DBG(ALIB_DLL const std::type_info& dbgTypeID() override { return typeid(Namespace CPPName); } ) \
123 ALIB_DLL void construct(VDATA* obj, PoolAllocator& pool) override { new (obj) Namespace CPPName(pool); } \
124 ALIB_DLL void destruct (VDATA* obj, PoolAllocator&) override { reinterpret_cast<Namespace CPPName*>(obj)->~CPPName(); } \
125 ALIB_DLL size_t size () override { static_assert(alignof(Namespace CPPName) <= alib::PoolAllocator::MAX_ALIGNMENT); return (std::max)( sizeof(Namespace CPPName), sizeof(void*) ); } \
126 ALIB_DLL void imPort (VDATA*, Configuration&, const StringEscaper&, const String&) override;\
127 ALIB_DLL void exPort (VDATA*, Configuration&, const StringEscaper&, AString&) override;\
128};}
129
130
131#define ALIB_VARIABLES_REGISTER_TYPE(CPPName) \
132 GetConfig()->RegisterType<alib::variables::detail::VMeta_ ## CPPName>();
133
134
135
136#endif
137#endif // HPP_ALIB_VARIABLES_PP
Definition alox.cpp:14
variables::Priority Priority
Type alias in namespace #"%alib".