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, ALOX, EXPRESSIONS, etc.
Types found in an ALib Module, will use the (inherited) method GetResourcePool and the method 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 the module ALib Bootstrap explains how bootstrapping and shutting down ALib is performed with the help of this class.
Furthermore, a 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.
To manage resources, this types derives from ResourceHolder. A fixed category name which is used with all resources by this camp, is expected in the constructor. The special camp BASECAMP uses "ALIB". Other ALib Camps use a short unique name.
Public Method Index: | |
| virtual void | Bootstrap ()=0 |
| void | BootstrapSetConfig (const SharedConfiguration &pConfig) |
| void | BootstrapSetPhase (BootstrapPhases phase) |
| void | BootstrapSetResourcePool (const SPResourcePool &pResourcePool) |
| BootstrapPhases | GetBootstrapState () |
| SharedConfiguration & | GetConfig () |
| bool | IsBootstrapped () |
| virtual void | Shutdown (ShutdownPhases phase)=0 |
| Public Method Index: inherited from alib::resources::ResourceHolder | |
| ResourceHolder (const NCString &resourceCategory=nullptr) | |
| ResourceHolder (SPResourcePool &pool, const NCString &resourceCategory) | |
| void | BootstrapResource (const NString &name, const String &data) |
| const String & | GetResource (const NString &name) |
| ResourcePool & | GetResourcePool () |
| SPResourcePool & | GetResourcePoolSP () |
| bool | HasPool () |
| void | Set (SPResourcePool &pool, const NCString &resourceCategory=nullptr) |
| const String & | TryResource (const NString &name) |
Protected Field Index: | |
| int | bootstrapState = 0 |
| SharedConfiguration | config |
| Protected Field Index: inherited from alib::resources::ResourceHolder | |
| SPResourcePool | resourcePool |
| Shared pointer to the resource pool. | |
Protected 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 | operator= (Camp &&)=delete |
| Deleted move assignment. | |
| void | operator= (const Camp &)=delete |
| Deleted copy assignment. | |
Additional Inherited Members | |
| Public Type Index: inherited from alib::resources::ResourceHolder | |
| using | SPResourcePool = SharedPtr<resources::ResourcePool, MonoAllocator> |
| Public Field Index: inherited from alib::resources::ResourceHolder | |
| NCString | ResourceCategory |
|
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.
|
inlineprotected |
Constructor.
| resourceCategory | Value for the inherited field ResourceCategory. |
|
inlineprotectedvirtual |
|
pure virtual |
Abstract method which is invoked during bootstrapping by function
Bootstrap(BootstrapPhases, camp::Camp*, 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 Bootstrap.
For details on bootstrappingALib Camps, see the detailed explanations in the Programmer's Manual of module ALib Bootstrap.
Implemented in alib::app::AppCliCamp, alib::camp::Basecamp, alib::cli::CliCamp, alib::expressions::ExpressionsCamp, alib::files::FilesCamp, and alib::lox::ALoxCamp.
|
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 the 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 |
|
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
Shutdown(ShutdownPhases, camp::Camp*) 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 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::app::AppCliCamp, alib::camp::Basecamp, alib::cli::CliCamp, alib::expressions::ExpressionsCamp, alib::files::FilesCamp, and alib::lox::ALoxCamp.