ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
configresourcepool.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_variables of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8
9ALIB_EXPORT namespace alib { namespace variables {
10#if !ALIB_SINGLE_THREADED || DOXYGEN
11/// This class provides an implementation of abstract interface class
12/// #"ResourcePool", which does externalize resources by using the mechanics
13/// provided with module \alib_variables.
14///
15/// A (shared) instance of this class can be attached to each \alibmod, by
16/// #"alib_mod_bs;customizing the bootstrapping of ALib".
17///
18/// \see
19/// Please consult the #"alib_mod_resources;Programmer's Manual" of module
20/// \alib_resources_nl for details on the concept of resources. Details on this specific type are
21/// given in chapter #"alib_resources_interface_config".
23 , public TSharedConfiguration<SharedLock> {
24
25#else
27 , public TSharedConfiguration<void> {
28#endif
29 protected:
30 /// Protected definition of inherited method.
31 /// @param createDefaults Determines if default plug-ins are to be created.
32 /// Defaults to \c Yes.
34 TSharedConfiguration::Reset(createDefaults);
35 }
36
37 public:
38 /// Constructor. Creates a configuration object without any default plug-ins.
39 /// After construction, the "resource data", in this case variable values, has to be added.
40 /// @param initialBufferSizeInKB The initial size of memory buffers.
41 /// Defaults to \c 16.
42 /// Passed to the constructor parent #"Configuration".
43 /// @param bufferGrowthInPercent Optional growth factor in percent, applied to the buffer size
44 /// with each next buffer allocation.
45 /// Should be set to \c 200, to double the size with each
46 /// allocation.
47 /// Defaults to \c 200.
48 /// Passed to the constructor parent #"Configuration".
49 ConfigResourcePool(size_t initialBufferSizeInKB = 4,
50 unsigned bufferGrowthInPercent = 200)
51 : TSharedConfiguration(initialBufferSizeInKB, bufferGrowthInPercent,
52 lang::CreateDefaults::No) {}
53
54 /// Default Destructor.
55 virtual ~ConfigResourcePool() override =default;
56
57 /// Implements abstract method #"ResourcePool::BootstrapAddOrReplace;*".
58 ///
59 /// @param category Category string of the resource.
60 /// @param name Name string of the resource
61 /// @param data The resource string.
62 /// @return \c true if the resource did exist and was replaced, \c false if it was an insertion.
63 bool BootstrapAddOrReplace( const NString& category,
64 const NString& name,
65 const String& data ) override;
66
67 /// Implements abstract method #"ResourcePool::BootstrapBulk;*".
68 /// All variables are written using #"Priority::DefaultValues".
69 ///
70 /// @param category Category string of the resource. For technical reasons, this has to be
71 /// of type <c>const nchar*</c>.
72 /// @param ... A list of pairs of <b>const nchar*</b> and <b>const character*</b>
73 /// keys and data.
75
76 virtual
77 void BootstrapBulk(const nchar *category, ...) override;
78
79#if DOXYGEN
80 /// Implements abstract method #"ResourcePool::Get;*".
81 ///
82 /// @param category Category string of the resource.
83 /// @param name Name string of the resource
84 /// @param dbgAssert This parameter is available (and to be passed) only in debug mode.
85 /// If \c true, an #"alib_mod_assert;error is raised" if the resource was not found.
86 /// @return The resource string, respectively a \e nulled string on failure.
88 const String& Get(const NString& category, const NString& name, bool dbgAssert) override;
89#else
91
92 const String& Get(const NString& category, const NString& name
93 ALIB_DBG(, bool dbgAssert)) override;
94#endif
95}; // class ConfigResourcePool
96} // namespace alib[::config]
97
98/// Type alias in namespace #"%alib".
100} // namespace [alib]
#define ALIB_DLL
#define ALIB_EXPORT
#define ALIB_DBG(...)
virtual void BootstrapBulk(const nchar *category,...) override
ConfigResourcePool(size_t initialBufferSizeInKB=4, unsigned bufferGrowthInPercent=200)
void Reset(lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
virtual ~ConfigResourcePool() override=default
Default Destructor.
bool BootstrapAddOrReplace(const NString &category, const NString &name, const String &data) override
void Reset(lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
CreateDefaults
Denotes whether default entities should be created or not.
@ Yes
Create default values.
Definition alox.cpp:14
strings::TString< nchar > NString
Type alias in namespace #"%alib".
Definition string.hpp:2174
resources::ResourcePool ResourcePool
Type alias in namespace #"%alib".
variables::ConfigResourcePool ConfigResourcePool
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
characters::nchar nchar
Type alias in namespace #"%alib".