From 56d42e9b045fa340a1ac115b8640d7e180f18890 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 5 Jan 2013 04:46:55 +0100 Subject: [PATCH] comments and tidying within BasicStetup and AppState --- src/common/appstate.cpp | 16 +++++++--------- src/common/appstate.hpp | 19 +++++++++++-------- src/common/basic-setup.hpp | 2 +- src/common/config.c | 6 +++--- src/common/config_typed.c | 8 ++++---- src/include/lifecycle.h | 14 +++++++------- src/lib/searchpath.cpp | 16 +++++++--------- src/lib/searchpath.hpp | 4 ++-- 8 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/common/appstate.cpp b/src/common/appstate.cpp index fca9c31b2..ceaa35a2f 100644 --- a/src/common/appstate.cpp +++ b/src/common/appstate.cpp @@ -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 diff --git a/src/common/appstate.hpp b/src/common/appstate.hpp index 8d44f09cd..f6f03b18c 100644 --- a/src/common/appstate.hpp +++ b/src/common/appstate.hpp @@ -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(); diff --git a/src/common/basic-setup.hpp b/src/common/basic-setup.hpp index 1385dd270..2f53da2bf 100644 --- a/src/common/basic-setup.hpp +++ b/src/common/basic-setup.hpp @@ -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. diff --git a/src/common/config.c b/src/common/config.c index 8fba63e36..54e3123b1 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -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) diff --git a/src/common/config_typed.c b/src/common/config_typed.c index 68083931f..4c1034b22 100644 --- a/src/common/config_typed.c +++ b/src/common/config_typed.c @@ -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; } diff --git a/src/include/lifecycle.h b/src/include/lifecycle.h index a3aa7c6a6..da4c526b3 100644 --- a/src/include/lifecycle.h +++ b/src/include/lifecycle.h @@ -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 diff --git a/src/lib/searchpath.cpp b/src/lib/searchpath.cpp index 86dccb015..2dda8d1d7 100644 --- a/src/lib/searchpath.cpp +++ b/src/lib/searchpath.cpp @@ -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 + } diff --git a/src/lib/searchpath.hpp b/src/lib/searchpath.hpp index 3505b9b69..816fea55c 100644 --- a/src/lib/searchpath.hpp +++ b/src/lib/searchpath.hpp @@ -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_() { }