ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Public Methods | Protected Fields | List of all members
ConfigResourcePool Class Reference

#include <configresourcepool.hpp>

Inheritance diagram for ConfigResourcePool:
[legend]
Collaboration diagram for ConfigResourcePool:
[legend]

Class Description


This class provides an implementation of abstract interface class ResourcePool, which does externalize resources by using the mechanics provided with module ALib Configuration.

A (shared) instance of this class can be attached to each ALib Module, with customization the bootstrapping of ALib.

See also
Please consult the Programmer's Manual of module ALib Resources for details on the concept of resources. Details on this specific type are given in chapter 4.2 Class ConfigResourcePool.

Definition at line 43 of file configresourcepool.hpp.

Public Fields

config::Configuration Config
 
- Public Fields inherited from ThreadLock
NCString DbgOwnerFile =nullptr
 
NCString DbgOwnerFunc =nullptr
 
int DbgOwnerLine
 
uint16_t DbgRecursionWarningThreshold =10
 
integer DbgWarningAfterWaitTimeInMillis =2000L
 

Public Methods

ALIB_API ConfigResourcePool ()
 
ALIB_API ~ConfigResourcePool () override
 
bool BootstrapAddOrReplace (const NString &category, const NString &name, const String &data) override
 
virtual ALIB_API void BootstrapBulk (const nchar *category,...) override
 
const NALIB_API StringGet (const NString &category, const NString &name, bool dbgAssert) override
 
- Public Methods inherited from ResourcePool
virtual ~ResourcePool ()
 
void Bootstrap (const NString &category, const NString &name, const String &data)
 
virtual ALIB_API std::vector< std::pair< NString, integer > > DbgGetCategories ()
 
virtual ALIB_API std::vector< std::tuple< NString, NString, String, integer > > DbgGetList ()
 
const StringGet (const NString &category, const String &name, bool dbgAssert)
 
- Public Methods inherited from ThreadLock
ALIB_API ThreadLock (Safeness safeness=Safeness::Safe)
 
ALIB_API ~ThreadLock ()
 
ALIB_API void Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
int CountAcquirements () const
 
ThreadGetOwner () const
 
Safeness GetSafeness () const
 
bool IsOwnedByCurrentThread () const
 
ALIB_API void Release ()
 defined(ALIB_DOX) More...
 
ALIB_API void SetSafeness (Safeness safeness)
 
bool WillRelease () const
 

Protected Fields

MonoAllocator allocator
 
detail::CachingResourceMap cache
 
config::Variable variable
 
- Protected Fields inherited from ThreadLock
uint16_t cntAcquirements =0
 
std::mutex mutex
 
std::condition_variable mutexNotifier
 
std::thread::id owner
 
Safeness safeness
 

Additional Inherited Members

- Public Static Methods inherited from ResourcePool
static ALIB_API AString DbgDump (std::vector< std::tuple< NString, NString, String, integer >> &list, const NString &catFilter=nullptr, const String &format=A_CHAR("({3:}) {1}={2!TAB20!ESC<!Q}\n"))
 

Constructor & Destructor Documentation

◆ ConfigResourcePool()

Constructor. Creates a configuration object without one plug-in of type InMemoryPlugin with default priority. After construction, one or more custom plug-ins have to be added. Those may be emplaced in this object's MonoAllocator

Definition at line 25 of file configresourcepool.cpp.

Here is the call graph for this function:

◆ ~ConfigResourcePool()

~ConfigResourcePool ( )
override

Destructor.

Definition at line 35 of file configresourcepool.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ BootstrapAddOrReplace()

bool BootstrapAddOrReplace ( const NString category,
const NString name,
const String data 
)
overridevirtual

Implements abstract method ResourcePool::BootstrapAddOrReplace.

Parameters
categoryCategory string of the resource.
nameName string of the resource
dataThe resource string.
Returns
true if the resource did exist and was replaced, false if it was an insertion.

Implements ResourcePool.

Definition at line 42 of file configresourcepool.cpp.

Here is the call graph for this function:

◆ BootstrapBulk()

void BootstrapBulk ( const nchar category,
  ... 
)
overridevirtual

Implements abstract method ResourcePool::BootstrapBulk.

Parameters
categoryCategory string of the resource. For technical reasons, this has to be of type const nchar*.
...A list of pairs of const nchar* and const character* keys and data.

Implements ResourcePool.

Definition at line 58 of file configresourcepool.cpp.

Here is the call graph for this function:

◆ Get()

const String & Get ( const NString category,
const NString name,
bool  dbgAssert 
)
overridevirtual

Implements abstract method ResourcePool::Get.

Parameters
categoryCategory string of the resource.
nameName string of the resource
dbgAssertThis parameter is available only in debug mode. If true, an assertion is raised if the resource was not found.
Returns
The resource string, respectively a nulled string on failure.

Implements ResourcePool.

Definition at line 80 of file configresourcepool.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ allocator

MonoAllocator allocator
protected

Monotonic allocator used for the hash map.

Definition at line 56 of file configresourcepool.hpp.

◆ cache

detail::CachingResourceMap cache
protected

A hash map used to store resources that have been acquired. While this also improves performance, a cache is needed to assure persistence of the values.

Definition at line 61 of file configresourcepool.hpp.

◆ Config

The configuration object for custom resource data.

Definition at line 71 of file configresourcepool.hpp.

◆ variable

config::Variable variable
protected

An only locally used object. Declared as field member to be reusable.

Definition at line 64 of file configresourcepool.hpp.


The documentation for this class was generated from the following files: