ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::resources::ResourceHolder Class Reference

Description:

A type serving as the base for types that hold a pointer to a LocalResourcePool and a fixed category string.

Note
The most prominent descendant of this type is class Camp.

Definition at line 220 of file resources.inl.

Inheritance diagram for alib::resources::ResourceHolder:
alib::camp::Camp alib::app::AppCliCamp alib::camp::Basecamp alib::cli::CliCamp alib::expressions::ExpressionsCamp alib::files::FilesCamp alib::lox::ALoxCamp

Public Type Index:

using SPResourcePool = SharedPtr<resources::ResourcePool, MonoAllocator>

Public Field Index:

NCString ResourceCategory

Public Method Index:

 ResourceHolder (const NCString &resourceCategory=nullptr)
 ResourceHolder (SPResourcePool &pool, const NCString &resourceCategory)
void BootstrapResource (const NString &name, const String &data)
const StringGetResource (const NString &name)
ResourcePoolGetResourcePool ()
SPResourcePoolGetResourcePoolSP ()
bool HasPool ()
void Set (SPResourcePool &pool, const NCString &resourceCategory=nullptr)
const StringTryResource (const NString &name)

Protected Field Index:

SPResourcePool resourcePool
 Shared pointer to the resource pool.

Type Definition Details:

◆ SPResourcePool

Type definition used for sharing resource-pool instances. With default-bootstrapping, an instance of type LocalResourcePool is used here, which is created with allocator instance GLOBAL_ALLOCATOR.

Definition at line 225 of file resources.inl.

Field Details:

◆ ResourceCategory

NCString alib::resources::ResourceHolder::ResourceCategory

The name of the resource category of externalized string resources defined and used by this resource holder.

Definition at line 234 of file resources.inl.

◆ resourcePool

SPResourcePool alib::resources::ResourceHolder::resourcePool
protected

Shared pointer to the resource pool.

Definition at line 229 of file resources.inl.

Constructor(s) / Destructor Details:

◆ ResourceHolder() [1/2]

alib::resources::ResourceHolder::ResourceHolder ( const NCString & resourceCategory = nullptr)
inline

Constructor.

Parameters
resourceCategoryValue for field ResourceCategory.

Definition at line 238 of file resources.inl.

◆ ResourceHolder() [2/2]

alib::resources::ResourceHolder::ResourceHolder ( SPResourcePool & pool,
const NCString & resourceCategory )
inline

Constructor.

Parameters
poolValue for the field resourcePool.
resourceCategoryValue for the field ResourceCategory.

Definition at line 244 of file resources.inl.

Method Details:

◆ BootstrapResource()

void alib::resources::ResourceHolder::BootstrapResource ( const NString & name,
const String & data )
inline

Shortcut method that invokes void Bootstrap(const NString&, const NString&, const String&)  on field resourcePool providing field ResourceCategory as a parameter.

Parameters
nameThe resource name.
dataThe resource data string.

Definition at line 267 of file resources.inl.

◆ GetResource()

const String & alib::resources::ResourceHolder::GetResource ( const NString & name)
inline

Shortcut method that invokes const String & Get(const NString&, const String&, bool)  on field resourcePool providing field ResourceCategory as parameter.

With debug-builds, this method asserts that a resource was found. If this is not wanted, use TryResource.

Parameters
nameThe resource name.
Returns
The resource string, respectively a nulled string on failure.

Definition at line 287 of file resources.inl.

◆ GetResourcePool()

ResourcePool & alib::resources::ResourceHolder::GetResourcePool ( )
inline

Returns a reference (not the shared-pointer!) to the resource pool held in our SharedPtr.

Returns
The resource pool instance.

Definition at line 277 of file resources.inl.

◆ GetResourcePoolSP()

SPResourcePool & alib::resources::ResourceHolder::GetResourcePoolSP ( )
inline

Returns a reference (!) to the shared pointer holding the resource pool.

Returns
The resource pool instance.

Definition at line 273 of file resources.inl.

◆ HasPool()

bool alib::resources::ResourceHolder::HasPool ( )
inline

Determines if a resource pool is set.

Returns
true if the field resourcePool is not nulled, false otherwise.

Definition at line 260 of file resources.inl.

◆ Set()

void alib::resources::ResourceHolder::Set ( SPResourcePool & pool,
const NCString & resourceCategory = nullptr )
inline

Constructor.

Parameters
poolValue for the field resourcePool.
resourceCategoryValue for field ResourceCategory. If not given (nulled), then the old value is preserved.

Definition at line 252 of file resources.inl.

◆ TryResource()

const String & alib::resources::ResourceHolder::TryResource ( const NString & name)
inline

Shortcut method that invokes const String & Get(const NString&, const String&, bool)  on field resourcePool providing field ResourceCategory as parameter.

Note
Usually, it is recommended to use GetResource, which asserts with debug-builds if a resource was not found.
Parameters
nameThe resource name.
Returns
The resource string, respectively a nulled string on failure.

Definition at line 301 of file resources.inl.


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