comments and tidying within BasicStetup and AppState
This commit is contained in:
parent
1c5ceaef15
commit
56d42e9b04
8 changed files with 42 additions and 43 deletions
|
|
@ -68,14 +68,13 @@ namespace lumiera {
|
|||
|
||||
|
||||
/** perform initialisation triggered on first access.
|
||||
* Will execute the ON_BASIC_INIT hook, but under typical
|
||||
* circumstances this is a NOP, because when callbacks are
|
||||
* added to this hook, the AppState singleton instance has
|
||||
* already been created. For this reason, there is special
|
||||
* treatment for the ON_BASIC_INIT in LifecycleHook::add,
|
||||
* causing the provided callbacks to be fired immediately.
|
||||
* (btw, this is nothing to be worried of, because from
|
||||
* client codes POV it just behaves like intended).
|
||||
* Will execute BasicSetup sequence to determine the location
|
||||
* of the executable and read in \c setup.ini --
|
||||
* Since above a LifecycleHook is installed ON_BASIC_INIT,
|
||||
* this can be expected to happen on static initialisation
|
||||
* of this compilation unit, if not earlier (if some other
|
||||
* static initialisation code accesses the instance).
|
||||
* @note all further application startup is conducted by \c main.cpp
|
||||
*/
|
||||
AppState::AppState()
|
||||
: setup_(LUMIERA_LOCATION_OF_BOOTSTRAP_INI)
|
||||
|
|
@ -124,7 +123,6 @@ namespace lumiera {
|
|||
lumiera_interfaceregistry_init ();
|
||||
_THROW_IF
|
||||
|
||||
TODO ("use a plugindb instead of loading all plugins at once");
|
||||
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
|
||||
_THROW_IF
|
||||
|
||||
|
|
|
|||
|
|
@ -94,9 +94,10 @@ namespace lumiera {
|
|||
string fetchSetupValue (lib::Literal key);
|
||||
|
||||
|
||||
/** building on the state determined by #evaluate, decide if the given Subsys
|
||||
/** building on the state determined by #init, decide if the given Subsys
|
||||
* needs to be pulled up and, if necessary, register the Subsys and its
|
||||
* prerequisites to be maintained throughout the application's lifetime. */
|
||||
* prerequisites to be maintained throughout the application's lifetime.
|
||||
*/
|
||||
void maybeStart (lumiera::Subsys&);
|
||||
|
||||
|
||||
|
|
@ -107,12 +108,14 @@ namespace lumiera {
|
|||
FAILED_EMERGENCY_EXIT
|
||||
};
|
||||
|
||||
/** put the main thread of the application into a wait state, if some subsystem(s)
|
||||
* registered with #maybeStart still need to be maintained. On termination of
|
||||
* one of those components, tear down the remaining components and initiate
|
||||
* a normal or emergency shutdown of the application, depending on the
|
||||
* triggering component's mode of termination (exit or exception).
|
||||
* @return global application exit code */
|
||||
/** put the main thread of the application into a wait state, as long as some
|
||||
* subsystem(s) registered with #maybeStart still need to be maintained.
|
||||
* On termination of one of those components, tear down the remaining
|
||||
* components and initiate a normal or emergency shutdown of the
|
||||
* application, depending on the triggering component's
|
||||
* mode of termination (exit or exception).
|
||||
* @return global application exit code
|
||||
*/
|
||||
ExitCode maybeWait();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace lumiera {
|
|||
* Lumiera executable; from there the initial configuration
|
||||
* locates a \c setup.ini to read in the fundamental settings.
|
||||
* This is even prerequisite for loading any extension modules
|
||||
* or reading in extended application configuration; usually
|
||||
* or reading any extended application configuration; usually
|
||||
* this bootstrap process happens at or before the start of
|
||||
* the \c main() function. Any failure leads to immediate
|
||||
* termination of the application.
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ lumiera_config_get (const char* key, const char** value)
|
|||
}
|
||||
else
|
||||
{
|
||||
TODO ("follow '<' delegates?");
|
||||
/////////////////////////TODO "follow '<' delegates?";
|
||||
LumieraConfigitem item = lumiera_config_lookup_item_find (&lumiera_global_config->keys, key);
|
||||
|
||||
if (item)
|
||||
|
|
@ -231,8 +231,8 @@ lumiera_config_get_default (const char* key, const char** value)
|
|||
|
||||
*value = NULL;
|
||||
|
||||
TODO ("follow '<' delegates?");
|
||||
TODO ("refactor _get and get_default to iterator access (return LList or Lookupentry)");
|
||||
/////////////////////////TODO follow '<' delegates?
|
||||
/////////////////////////TODO refactor _get and get_default to iterator access (return LList or Lookupentry)
|
||||
LumieraConfigitem item = lumiera_config_lookup_item_tail_find (&lumiera_global_config->keys, key);
|
||||
|
||||
if (item && item->parent == &lumiera_global_config->defaults)
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ lumiera_config_wordlist_get (const char* key, const char** value)
|
|||
else
|
||||
LUMIERA_ERROR_SET_WARNING (config, CONFIG_NO_ENTRY, key);
|
||||
|
||||
TODO ("remove the ERROR_SET because config_get sets it already? also in all other getters in this file");
|
||||
/////////////////////////TODO "remove the ERROR_SET because config_get sets it already? also in all other getters in this file
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +339,7 @@ lumiera_config_word_set (const char* key, const char** value)
|
|||
|
||||
LUMIERA_MUTEX_SECTION (mutex_sync, &lumiera_global_config->lock)
|
||||
{
|
||||
const char* fmt = "= %s"; TODO ("use the config system (config.format*...) to deduce the desired format for this key");
|
||||
const char* fmt = "= %s"; ///////////////////////TODO use the config system (config.format*...) to deduce the desired format for this key
|
||||
item = lumiera_config_set (key, lumiera_tmpbuf_snprintf (SIZE_MAX, fmt, scan_word (*value)));
|
||||
}
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ lumiera_config_bool_get (const char* key, int* value)
|
|||
{
|
||||
(void) key; (void) value;
|
||||
TRACE (configtyped_dbg);
|
||||
UNIMPLEMENTED();
|
||||
UNIMPLEMENTED("get bool from config system");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ lumiera_config_bool_set (const char* key, int* value)
|
|||
{
|
||||
(void) key; (void) value;
|
||||
TRACE (configtyped_dbg);
|
||||
UNIMPLEMENTED();
|
||||
UNIMPLEMENTED("set bool in config system");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
*/
|
||||
|
||||
/** @file lifecycle.h
|
||||
** Interface for registering and triggering application lifecycle event callbacks.
|
||||
** This service is a facade for and implemented by lumiera::AppState.
|
||||
** Installing and invoking of application lifecycle event callbacks.
|
||||
** This service is a facade for and implemented by the lumiera::LifecycleRegistry.
|
||||
** By placing a static LifecycleHook variable or by calling LifecycleHook::add,
|
||||
** a callback can be registered to be executed on a specific application lifecycle
|
||||
** event. Examples being #ON_BASIC_INIT, #ON_GLOBAL_INIT. Other subsystems may
|
||||
|
|
@ -50,7 +50,7 @@ namespace lumiera {
|
|||
using lib::Symbol;
|
||||
|
||||
//defined in liblumiera.so
|
||||
extern const char * ON_BASIC_INIT; ///< automatic static init. treated specially
|
||||
extern const char * ON_BASIC_INIT; ///< automatic static init. treated specially to run as soon as possible
|
||||
extern const char * ON_GLOBAL_INIT; ///< to be triggered in main() @note no magic!
|
||||
extern const char * ON_GLOBAL_SHUTDOWN; ///< to be triggered at the end of main() @note no magic!
|
||||
|
||||
|
|
@ -65,12 +65,12 @@ namespace lumiera {
|
|||
* define and register a callback for a specific lifecycle event.
|
||||
* The purpose of this class is to be defined as a static variable in the implementation
|
||||
* of some subsystem (i.e. in the cpp file), providing the ctor with the pointer to a
|
||||
* callback function. Thus the callback gets enroled when the corresponding object file
|
||||
* is loaded. The event ON_BASIC_INIT is handled specifically, firing off the referred
|
||||
* callback function as soon as possible. All other labels are just arbitrary (string)
|
||||
* callback function. Thus the specified callback gets enrolled when the corresponding
|
||||
* object file is loaded. The event ON_BASIC_INIT is handled specifically, firing off the
|
||||
* referred callback function as soon as possible. All other labels are just arbitrary (string)
|
||||
* constants and it is necessary that "someone" cares to fire off the lifecycle events
|
||||
* at the right place. For example, lumiera-main (and the test runner) calls
|
||||
* \c AppState::instance().execute(ON_GLOBAL_INIT) (and..SHUTDOWN)
|
||||
* \c LifecycleHook::trigger(ON_GLOBAL_INIT) (and..SHUTDOWN)
|
||||
* @note duplicate or repeated calls with the same callback are NOP
|
||||
*/
|
||||
class LifecycleHook
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace lib {
|
|||
* @note also picks ORIGIN, $ORIGIN/, ORIGIN/
|
||||
*/
|
||||
string
|
||||
replaceTokens (string const& src)
|
||||
replaceMagicLinkerTokens (string const& src)
|
||||
{
|
||||
static const regex PICK_ORIGIN_TOKEN ("\\$?ORIGIN/?");
|
||||
static const string expandedOriginDir
|
||||
|
|
@ -86,21 +86,19 @@ namespace lib {
|
|||
fsys::path modulePathName (moduleName);
|
||||
SearchPathSplitter searchLocation(searchPath); ///////////TICKET #896
|
||||
|
||||
while (true)
|
||||
while (!fsys::exists (modulePathName))
|
||||
{
|
||||
if (fsys::exists (modulePathName))
|
||||
{
|
||||
INFO (config, "found module %s", modulePathName.string().c_str());
|
||||
return modulePathName.string(); ///////////TICKET #896
|
||||
}
|
||||
|
||||
// try / continue search path
|
||||
if (searchLocation.isValid())
|
||||
modulePathName = fsys::path() / searchLocation.next() / moduleName;
|
||||
else
|
||||
throw error::Config ("Module \""+moduleName.string()+"\" not found" /////TICKET #896
|
||||
+ (searchPath.empty()? ".":" in search path: "+searchPath));
|
||||
} }
|
||||
}
|
||||
|
||||
INFO (config, "found module %s", modulePathName.string().c_str());
|
||||
return modulePathName.string(); ///////////TICKET #896
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace lib {
|
|||
|
||||
/** replace $ORIGIN tokens in the given string
|
||||
* @return copy with expansions applied */
|
||||
string replaceTokens (string const& src);
|
||||
string replaceMagicLinkerTokens (string const& src);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +77,7 @@ namespace lib {
|
|||
|
||||
public:
|
||||
SearchPathSplitter (string const& searchPath)
|
||||
: pathSpec_(replaceTokens (searchPath))
|
||||
: pathSpec_(replaceMagicLinkerTokens (searchPath))
|
||||
, pos_(pathSpec_.begin(),pathSpec_.end(), EXTRACT_PATHSPEC)
|
||||
, end_()
|
||||
{ }
|
||||
|
|
|
|||
Loading…
Reference in a new issue