This class is used by ALib to
Typically, every "bigger" and "higher level" ALib Module disposes of 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 Programmer's Manual of module ALib Bootstrap explains how 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.
Public Type Index: | |
using | SPResourcePool = SharedPtr<resources::ResourcePool, MonoAllocator> |
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. | |
virtual void | Bootstrap ()=0 |
void | BootstrapResource (const NString &name, const String &data) |
void | BootstrapSetConfig (const SharedConfiguration &pConfig) |
void | BootstrapSetPhase (BootstrapPhases phase) |
void | BootstrapSetResourcePool (const SPResourcePool &pResourcePool) |
BootstrapPhases | GetBootstrapState () |
SharedConfiguration & | GetConfig () |
const String & | GetResource (const NString &name) |
SPResourcePool & | GetResourcePool () |
bool | IsBootstrapped () |
void | operator= (Camp &&)=delete |
Deleted move assignment. | |
void | operator= (const Camp &)=delete |
Deleted copy assignment. | |
virtual void | Shutdown (ShutdownPhases phase)=0 |
const String & | TryResource (const NString &name) |
Protected Field Index: | |
int | bootstrapState = 0 |
SharedConfiguration | config |
SPResourcePool | resourcePool |
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.
|
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.
NCString alib::camp::Camp::ResourceCategory |
|
protected |
Shared pointer to the resource pool.
|
inline |
Constructor.
resourceCategory | Value for field ResourceCategory. |
|
inlinevirtual |
|
pure virtual |
Abstract method which is invoked during bootstrapping by function
alib::Bootstrap(BootstrapPhases targetPhase, camp::Camp* targetCamp, int,int,TCompilationFlags) for each phase, and each camp found in list CAMPS. Implementations of this function receive the phase to perform with GetBootstrapState.
This method is not to be called from outside, but is internally invoked by function alib::Bootstrap.
For details on bootstrappingALib Camps, see the detailed explanations in the Programmer's Manual of module ALib Bootstrap.
Implemented in alib::camp::Basecamp, alib::cli::CliCamp, alib::expressions::ExpressionsCamp, alib::files::FilesCamp, and alib::lox::ALoxCamp.
Shortcut method that invokes ResourcePool::Bootstrap on field resourcePool providing field ResourceCategory as parameter.
name | The resource name. |
data | The resource data string. |
|
inline |
Sets the configuration instance of this camp.
pConfig | The configuration to use. |
|
inline |
|
inline |
Sets the resource pool of this camp. By default, this function is called with pResourcePool holding an instance of type LocalResourcePool when ALib is bootstrapped.
In case a custom resource pool type (and/or instance) should be used with this camp, a custom shared pointer has to be created and the custom pool has to be inserted (potentially using method SharedPtr::InsertDerived). Then this method has to be called on the camp prior to the invocation of alib::Bootstrap.
Note that the Function alib::Bootstrap will distribute the given instance to each lower-level camp that has not received a different object. If this should be avoided (to separate the resources of this camp from lower level camps), a further customized bootstrap strategy has to be implemented.
pResourcePool | The resource pool to use. |
|
inline |
|
inline |
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. |
|
inline |
|
inline |
Tests if this ALib Camp was completely initialized.
true
if the initialization state is either BootstrapPhases::Final or ShutdownPhases::Announce, false
otherwise.
|
pure virtual |
Abstract method which is invoked during bootstrapping by function
alib::Shutdown(ShutdownPhases targetPhase, camp::Camp* targetCamp) for each phase, and each camp found in list CAMPS.
This method is not to be called from outside, but is internally invoked by function alib::Bootstrap.
For details on bootstrapping ALib Camps, see the detailed explanations in the Programmer's Manual of module ALib Bootstrap.
phase | The termination level to perform. |
Implemented in alib::camp::Basecamp, alib::cli::CliCamp, alib::expressions::ExpressionsCamp, alib::files::FilesCamp, and alib::lox::ALoxCamp.
Shortcut method that invokes ResourcePool::Get on field resourcePool providing field ResourceCategory as parameter.
name | The resource name. |