From 010b0d99ff79cf7cacb2435e0de136cfe68237ad Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 1 Dec 2008 05:35:19 +0100 Subject: [PATCH] AppState implementation skeleton --- src/lumiera/appstate.cpp | 46 ++++++++++++++++++++++++++++++++++++++++ src/lumiera/appstate.hpp | 38 +++++++++++++++++++++++++++++++++ src/lumiera/main.cpp | 2 +- src/lumiera/option.cpp | 2 +- src/lumiera/option.hpp | 4 ++-- src/proc/asset.cpp | 9 ++++---- 6 files changed, 92 insertions(+), 9 deletions(-) diff --git a/src/lumiera/appstate.cpp b/src/lumiera/appstate.cpp index 4df6b743e..af84fbe95 100644 --- a/src/lumiera/appstate.cpp +++ b/src/lumiera/appstate.cpp @@ -80,6 +80,52 @@ namespace lumiera { + void + AppState::evaluate (lumiera::Option& options) + { + UNIMPLEMENTED ("evaluate the options and set global application state"); + } + + + + void + AppState::maybeStart (lumiera::Subsys&) + { + UNIMPLEMENTED ("maybe register and activate the given subsystem"); + } + + + + using AppState::ExitCode; + + + ExitCode + AppState::maybeWait() + { + UNIMPLEMENTED ("wait on termination and normal shutdown"); + } + + + + ExitCode + AppState::abort (lumiera::Error& problem) + { + UNIMPLEMENTED ("clean error shutdown"); + } + + + + ExitCode + AppState::abort () + { + UNIMPLEMENTED ("emergency shutdown"); + } + + + + + + // ==== implementation LifecycleHook class ======= diff --git a/src/lumiera/appstate.hpp b/src/lumiera/appstate.hpp index 7339fa235..5176159c8 100644 --- a/src/lumiera/appstate.hpp +++ b/src/lumiera/appstate.hpp @@ -80,7 +80,45 @@ namespace lumiera { static void lifecycle (Symbol eventLabel); + /** evaluate the command line options and maybe additional configuration + * such as to be able to determine the further behaviour of the application. + * Set the internal state within this object accordingly */ + void evaluate (lumiera::Option& options); + + /** building on the state determined by #evaluate, 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. */ + void maybeStart (lumiera::Subsys&); + + + enum ExitCode { + NORMAL_EXIT, + CLEAN_EXIT_AFTER_ERROR, + CLEAN_EMERGENCY_EXIT, + 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 */ + ExitCode maybeWait(); + + + /** initiate the controlled error shutdown sequence + * @param problem causing exception */ + ExitCode abort (lumiera::Error& problem); + + + /** initiate an fatal emergency shutdown, + * caused by an unforeseen error condition */ + ExitCode abort (); + + + private: typedef scoped_ptr PLife; diff --git a/src/lumiera/main.cpp b/src/lumiera/main.cpp index 4eaf62021..fd9c8601d 100644 --- a/src/lumiera/main.cpp +++ b/src/lumiera/main.cpp @@ -73,7 +73,7 @@ main (int argc, const char* argv[]) application.maybeStart (lumigui); application.maybeStart (script); - return 0; // main thread terminating after successful startup + return application.maybeWait(); } diff --git a/src/lumiera/option.cpp b/src/lumiera/option.cpp index cabedf9e3..2e6b14f0f 100644 --- a/src/lumiera/option.cpp +++ b/src/lumiera/option.cpp @@ -113,7 +113,7 @@ namespace lumiera { ostream& - operator<< (ostream& os, const TestOption& to) + operator<< (ostream& os, const Option& to) { return os << to.syntax; } diff --git a/src/lumiera/option.hpp b/src/lumiera/option.hpp index 6bcacb47a..c93e4ad4e 100644 --- a/src/lumiera/option.hpp +++ b/src/lumiera/option.hpp @@ -62,13 +62,13 @@ namespace lumiera { boost::program_options::options_description syntax; boost::program_options::variables_map parameters; - friend ostream& operator<< (ostream&, const TestOption&); + friend ostream& operator<< (ostream&, const Option&); }; /** for outputting the help messages. Forward accumulated * help messages from all contained option definitions */ - ostream& operator<< (ostream& os, const TestOption& to); + ostream& operator<< (ostream& os, const Option& to); } // namespace lumiera diff --git a/src/proc/asset.cpp b/src/proc/asset.cpp index 668cbb2ba..e576b4b44 100644 --- a/src/proc/asset.cpp +++ b/src/proc/asset.cpp @@ -1,5 +1,5 @@ /* - Asset} - Superinterface: bookeeping view of "things" present in the session + Asset - Superinterface: bookkeeping view of "things" present in the session Copyright (C) Lumiera.org 2008, Hermann Vosseler @@ -40,8 +40,7 @@ using util::and_all; using util::cStr; -namespace asset - { +namespace asset { using ::NOBUG_FLAG(memory); NOBUG_CPP_DEFINE_FLAG_PARENT(assetmem, memory); @@ -96,7 +95,7 @@ namespace asset } /** - * whether this asset is swithced on and consequently included + * whether this asset is switched on and consequently included * in the fixture and participates in rendering. */ bool @@ -137,7 +136,7 @@ namespace asset other->unlink (this->id); } - /** release all links to other dependant + /** release all links to other dependent * asset objects held internally and advise all parent * assets to do so with the link to this asset. * @note we don't release upward links to parent assets,