#include <configresourcepool.hpp>
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.
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 String & | Get (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 String & | Get (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 |
| Thread * | GetOwner () 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. 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.
|
override |
Destructor.
Definition at line 35 of file configresourcepool.cpp.
|
overridevirtual |
Implements abstract method ResourcePool::BootstrapAddOrReplace.
| category | Category string of the resource. |
| name | Name string of the resource |
| data | The resource string. |
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.
|
overridevirtual |
Implements abstract method ResourcePool::BootstrapBulk.
| category | Category 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.
|
overridevirtual |
Implements abstract method ResourcePool::Get.
| category | Category string of the resource. |
| name | Name string of the resource |
| dbgAssert | This parameter is available only in debug mode. If true, an assertion is raised if the resource was not found. |
Implements ResourcePool.
Definition at line 80 of file configresourcepool.cpp.
|
protected |
Monotonic allocator used for the hash map.
Definition at line 56 of file configresourcepool.hpp.
|
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::Configuration Config |
The configuration object for custom resource data.
Definition at line 71 of file configresourcepool.hpp.
|
protected |
An only locally used object. Declared as field member to be reusable.
Definition at line 64 of file configresourcepool.hpp.