This class is used by ALib to
Typically, every "bigger" and "higher level" ALib Module disposes about a type derived from this class. The singleton instances of these types are collected in namespace alib and are named in capital letters, for example alib::ALOX, alib::EXPRESSIONS, etc.
Types found in an ALib Module, will use methods GetResourcePool and GetConfig of that singleton to access resources and to read and write configuration data. With that, it has to be kept in mind that these objects most probably are shared with other camps. As a consequence, clear and understandable resource and variable categories and names are to be used, to avoid conflicting entries.
The ALib Programmer's Manual provides several chapters that explain how 4. Bootstrapping And Shutting Down ALib is performed with the help of this class.
Furthermore, source code sample is given with the tutorial of ALib Module CLI.
Often, types that comprise a "camp singleton" (as the derived types shown in the inheritance diagram above) incorporate some further functionality specific to the field of application that a "module" respectively "camp" covers.
#include <camp.hpp>
Public Field Index: | |
NCString | ResourceCategory |
Public Method Index: | |
Camp (Camp &&)=delete | |
Deleted move constructor. | |
Camp (const Camp &)=delete | |
Deleted copy constructor. | |
Camp (const NCString &resourceCategory) | |
virtual | ~Camp () |
Virtual destructor to satisfy C++ abstract type rules. | |
void | BootstrapResource (const NString &name, const String &data) |
void | BootstrapSetConfig (config::Configuration *pConfig) |
void | BootstrapSetResourcePool (lang::resources::ResourcePool *pool) |
config::Configuration & | GetConfig () |
threads::SharedLock & | GetConfigLock () |
const String & | GetResource (const NString &name) |
resources::ResourcePool & | GetResourcePool () |
bool | IsBootstrapped () |
void | operator= (Camp &&)=delete |
Deleted move assignment. | |
void | operator= (const Camp &)=delete |
Deleted copy assignment. | |
const String & | TryResource (const NString &name) |
Protected Field Index: | |
int | bootstrapState = 0 |
config::Configuration * | config = nullptr |
SharedLock * | configLock |
A shared lock associated to member config. | |
bool | isConfigOwner = false |
bool | isResourceOwner = false |
lang::resources::ResourcePool * | resourcePool = nullptr |
Protected Method Index: | |
virtual void | bootstrap (BootstrapPhases phase)=0 |
virtual void | shutdown (ShutdownPhases phase)=0 |
|
protected |
|
protected |
Pointer to the configuration instance used to load variable configuration data. An instance is created and assigned with the invocation of one of the Bootstrap methods. This instance is then passed to all dependent libraries (recursively) and this way shared. Dependent libraries that are to an own dedicated instance, have to be initialized explicitly before initializing this ALib Camp.
Access to the field is provided with method GetConfig.
|
protected |
|
protected |
If a configuration instance has been created when this ALib Camp was initialized, this flag evaluates to true
and the instance stored in config will be deleted with destruction of this object.
|
protected |
If a default instance of type LocalResourcePool has been created when this camp was initialized, this flag evaluates to true
and the instance stored in resourcePool will be deleted with destruction of this object.
NCString ResourceCategory |
The name of the resource category of externalized string resources defined and used by this ALib Camp.
Special camp ALib BaseCamp uses "ALIB". Other ALib Camps use a short unique name.
|
protected |
Pointer to the resource pool. An instance is created and assigned with the invocation of one of the Bootstrap methods. This instance is then passed to all dependent camps (recursively) and this way shared. Dependent libraries that are to an own dedicated instance, have to be initialized explicitly before initializing this ALib Camp.
Constructor.
resourceCategory | Value for field ResourceCategory. |
|
inlinevirtual |
|
protectedpure virtual |
Abstract method which is invoked during bootstrapping by function
alib::Bootstrap(BootstrapPhases targetPhase. for each phase, and each camp found in list CAMPS.
For details on bootstrapping ALib Camps, see the detailed explanations in chapter 4.Bootstrapping And Shutting Down ALib of the ALib Programmer's Manual.
phase | The initialization phase to perform. |
Implemented in CliCamp, ConfigCamp, ExpressionsCamp, FilesCamp, BaseCamp, and ALoxCamp.
Shortcut method that invokes ResourcePool::Bootstrap on field resourcePool providing field ResourceCategory as parameter.
name | The resource name. |
data | The resource data string. |
Definition at line 15 of file camp_inlines.hpp.
|
inline |
Sets the configuration object of this ALib Camp.
pConfig | The external configuration object to use. |
|
inline |
Sets the resource pool of this camp.
pool | The external resource pool to use. |
|
inline |
Returns a reference to the configuration object.
|
inline |
Returns a reference to the shared lock that is associated with the configuration object receivable with GetConfig.
Shortcut method that invokes ResourcePool::Get 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.
name | The resource name. |
Definition at line 16 of file camp_inlines.hpp.
|
inline |
|
inline |
Tests if this ALib Camp was completely initialized.
true
if the initialization state is either BootstrapPhases::Final or ShutdownPhases::Announce, false
otherwise.
|
protectedpure virtual |
Abstract method which is invoked during bootstrapping by function
alib::Shutdown(ShutdownPhases targetPhase for each phase, and each camp found in list CAMPS.
For details on bootstrapping ALib Camps, see the detailed explanations in chapter 4. Bootstrapping And Shutting Down ALib of the ALib Programmer's Manual.
phase | The termination level to perform. |
Implemented in CliCamp, ConfigCamp, ExpressionsCamp, FilesCamp, BaseCamp, and ALoxCamp.
Shortcut method that invokes ResourcePool::Get on field resourcePool providing field ResourceCategory as parameter.
name | The resource name. |
Definition at line 17 of file camp_inlines.hpp.