ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::camp::Camp Class Referenceabstract

Description:

This class is used by ALib to

  • manage library bootstrap and termination,
  • provide resources and to
  • provide Configuration data (e.g., configuration files, command-line parameters, etc.).

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.

Reference Documentation

Definition at line 85 of file camp.inl.

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

Public Method Index:

virtual void Bootstrap ()=0
void BootstrapSetConfig (const SharedConfiguration &pConfig)
void BootstrapSetPhase (BootstrapPhases phase)
void BootstrapSetResourcePool (const SPResourcePool &pResourcePool)
BootstrapPhases GetBootstrapState ()
SharedConfigurationGetConfig ()
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 StringGetResource (const NString &name)
ResourcePoolGetResourcePool ()
SPResourcePoolGetResourcePoolSP ()
bool HasPool ()
void Set (SPResourcePool &pool, const NCString &resourceCategory=nullptr)
const StringTryResource (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

Field Details:

◆ bootstrapState

int alib::camp::Camp::bootstrapState = 0
protected

State of initialization, used to avoid double initialization as well as initialization "gaps".

Definition at line 89 of file camp.inl.

◆ config

SharedConfiguration alib::camp::Camp::config
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.

Definition at line 98 of file camp.inl.

Constructor(s) / Destructor Details:

◆ Camp()

alib::camp::Camp::Camp ( const NCString & resourceCategory)
inlineprotected

Constructor.

Parameters
resourceCategoryValue for the inherited field ResourceCategory.

Definition at line 106 of file camp.inl.

◆ ~Camp()

virtual alib::camp::Camp::~Camp ( )
inlineprotectedvirtual

Virtual destructor to satisfy C++ abstract type rules.

Definition at line 123 of file camp.inl.

Method Details:

◆ Bootstrap()

virtual void alib::camp::Camp::Bootstrap ( )
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.

◆ BootstrapSetConfig()

void alib::camp::Camp::BootstrapSetConfig ( const SharedConfiguration & pConfig)
inline

Sets the configuration instance of this camp.

Attention
Note the documentation of the sibling method BootstrapSetResourcePool. Here, the very same rules apply in respect to the distribution of configuration instances between different camps and in respect to the customization of bootstrapping.
See also
Chapter 7. Customizing The Bootstrap Process of the Programmer's Manual of module ALib Bootstrap.
Parameters
pConfigThe configuration to use.

Definition at line 188 of file camp.inl.

◆ BootstrapSetPhase()

void alib::camp::Camp::BootstrapSetPhase ( BootstrapPhases phase)
inline

Sets the (next) bootstrap phase to perform.

Parameters
phaseThe upcoming phase.

Definition at line 164 of file camp.inl.

◆ BootstrapSetResourcePool()

void alib::camp::Camp::BootstrapSetResourcePool ( const SPResourcePool & pResourcePool)
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.

Parameters
pResourcePoolThe resource pool to use.

Definition at line 214 of file camp.inl.

◆ GetBootstrapState()

BootstrapPhases alib::camp::Camp::GetBootstrapState ( )
inline

Returns the bootstrap state of this camp.

Returns
The internal state flag.

Definition at line 160 of file camp.inl.

◆ GetConfig()

SharedConfiguration & alib::camp::Camp::GetConfig ( )
inline

Returns a reference (!) to the configuration object.

Returns
The configuration object set with bootstrapping.

Definition at line 197 of file camp.inl.

◆ IsBootstrapped()

bool alib::camp::Camp::IsBootstrapped ( )
inline

Tests if this ALib Camp was completely initialized.

Returns
true if the initialization state is either BootstrapPhases::Final or ShutdownPhases::Announce, false otherwise.

Definition at line 169 of file camp.inl.

◆ Shutdown()

virtual void alib::camp::Camp::Shutdown ( ShutdownPhases phase)
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.

Parameters
phaseThe 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.


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