This purely abstract class provides an interface to store and retrieve "resourced" string data which are organized in a two-level key hierarchy named "resource category" and "resource name". The latter are of narrow string-type.
Definition at line 23 of file resources.inl.
Public Method Index: | |
virtual | ~ResourcePool ()=default |
Virtual destructor. | |
void | Bootstrap (const NString &category, const NString &name, const String &data) |
virtual bool | BootstrapAddOrReplace (const NString &category, const NString &name, const String &data)=0 |
virtual void | BootstrapBulk (const nchar *category,...)=0 |
virtual ALIB_DLL std::vector< std::pair< NString, integer > > | DbgGetCategories () |
virtual ALIB_DLL std::vector< std::tuple< NString, NString, String, integer > > | DbgGetList () |
virtual const String & | Get (const NString &category, const NString &name, bool dbgAssert)=0 |
const String & | Get (const NString &category, const String &name, bool dbgAssert) |
|
inline |
Simple inline method that invokes virtual method BootstrapAddOrReplace. In debug-compilations, it is asserted that a resource with the given key did not exist already.
The use of this method is preferred over a direct invocation of BootstrapAddOrReplace.
category | Category string of the resource to add. |
name | Name string of the resource. |
data | The resource data. |
Definition at line 68 of file resources.inl.
|
pure virtual |
Used to store a resource string.
In the context of ALib Modules, which usually are the only areas where instances of this type are available (used), this method must only be invoked during the process of bootstrapping ALib (and corresponding custom modules).
category | Category string of the resource to add. |
name | Name string of the resource. |
data | The resource data. |
true
if the resource did exist and was replaced, false
if it was an insertion. Implemented in alib::resources::LocalResourcePool, and alib::variables::ConfigResourcePool.
|
pure virtual |
Same as Bootstrap but accepts an array of name/value pairs to be filled into the given parameter category.
nullptr
argument for the next name!In the context of ALib Modules, which usually are the only areas where instances of this type are available (used), this method must only invoked during the process of bootstrapping ALib (and corresponding custom modules).
"..."
in general is not recommended to be used. We still do it here, because this method is usually used with implementations of Camp::Bootstrap to load static default values. This approach saves a lot of otherwise needed single invocations (reduces code size) and allows a clean code for the init methods.const nchar*
.category | The category of the resources given. |
... | A list of pairs of const nchar* and const character* keys and data, including a terminating nullptr value. |
Implemented in alib::resources::LocalResourcePool, and alib::variables::ConfigResourcePool.
|
virtual |
Implements abstract method ResourcePool::DbgGetCategories.
Reimplemented in alib::resources::LocalResourcePool.
Definition at line 142 of file localresourcepool.cpp.
|
virtual |
Returns a vector of tuples for each resourced element. Each tuple contains:
While being useful to generaly inspect the resources, a high number of requests might indicate a performance penalty for a using software. Such can usually be mitigated in a very simple fashion by "caching" a resource string in a local or global/static string variable.
Reimplemented in alib::resources::LocalResourcePool.
Definition at line 132 of file localresourcepool.cpp.
|
pure virtual |
Returns a resource. On failure (resource not found), a nulled string is returned.
category | Category string of the resource. |
name | Name string of the resource |
dbgAssert | This parameter is available (and to be passed) only in debug mode. If true , an error is raised if the resource was not found. |
Implemented in alib::resources::LocalResourcePool, and alib::variables::ConfigResourcePool.
const String & alib::resources::ResourcePool::Get | ( | const NString & | category, |
const String & | name, | ||
bool | dbgAssert ) |
Convenience inlined method that accepts parameter name as character instead of nchar based string-type. The rationale for this is that often, resource name keys are read from other resourced strings and need conversion if used. This avoids external conversion before invoking this method.
This method is available only when ALib is compiled with type character not being equivalent to nchar.
After the string conversion, this method simply returns the result of virtual method Get(const NString&, const NString&, bool).
category | Category string of the resource. |
name | Name string of the resource |
dbgAssert | This parameter is available (and to be passed) only in debug mode. If true , an error is raised if the resource was not found. |