diff --git a/src/backend/enginefacade.cpp b/src/backend/enginefacade.cpp index 633fc1425..5c2ff789c 100644 --- a/src/backend/enginefacade.cpp +++ b/src/backend/enginefacade.cpp @@ -59,7 +59,9 @@ namespace backend { }; - static lumiera::Singleton theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! + namespace { + lumiera::Singleton theDescriptor; + } diff --git a/src/backend/netnodefacade.cpp b/src/backend/netnodefacade.cpp index 3d520a1eb..6f9a5098b 100644 --- a/src/backend/netnodefacade.cpp +++ b/src/backend/netnodefacade.cpp @@ -58,7 +58,9 @@ namespace backend { }; - static lumiera::Singleton theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! + namespace { + lumiera::Singleton theDescriptor; + } diff --git a/src/backend/scriptrunnerfacade.cpp b/src/backend/scriptrunnerfacade.cpp index a04518fe0..3a329a905 100644 --- a/src/backend/scriptrunnerfacade.cpp +++ b/src/backend/scriptrunnerfacade.cpp @@ -59,7 +59,9 @@ namespace backend { }; - static lumiera::Singleton theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! + namespace { + lumiera::Singleton theDescriptor; + } diff --git a/src/common/configrules.cpp b/src/common/configrules.cpp index 18edc4f40..8d121532b 100644 --- a/src/common/configrules.cpp +++ b/src/common/configrules.cpp @@ -40,14 +40,14 @@ namespace lumiera } // namespace query - namespace - { + namespace { + /** type of the actual ConfigRules implementation to use */ singleton::UseSubclass typeinfo; } - /** Singleton factory instance, parametrized to actual impl. type. */ + /** Singleton factory instance, parametrised to actual impl. type. */ SingletonSub ConfigRules::instance (typeinfo); diff --git a/src/common/configrules.hpp b/src/common/configrules.hpp index e80ccfa8a..7b015dfdd 100644 --- a/src/common/configrules.hpp +++ b/src/common/configrules.hpp @@ -31,7 +31,7 @@ ** preconfigured Map. ** ** Fully implementing this facility would require the participating objects to register capabilities - ** they want to provide, together with functors carrying out the neccessary configuration steps. + ** they want to provide, together with functors carrying out the necessary configuration steps. ** All details and consequences of this approach still have to be worked out... ** ** @note this is rather a scrapbook and in flux... don't take this code too literal! @@ -79,7 +79,7 @@ namespace lumiera // // stream(T, mpeg) :- type(T, track), type(P, pipe), resolve(P, stream(P,mpeg)), place_to(P, T). // - // The type guard is inserted auomatically, while the predicate implementations for + // The type guard is inserted automatically, while the predicate implementations for // find/1, make/1, stream/2, and place_to/2 are to be provided by the target types. // // As a example, the goal ":-retrieve(T, stream(T,mpeg))." would search a Track object, try to @@ -102,7 +102,7 @@ namespace lumiera }; /** - * the "backside" interface towards the classes participating + * the "back side" interface towards the classes participating * in the configuration system (the config system will be * delivering instances of these classes for a given query). * This one currently is just brainstorming. The idea is that @@ -127,7 +127,7 @@ namespace lumiera }; /** - * the "frontside" interface: the Proc-Layer code can + * the "front side" interface: the Proc-Layer code can * use this QueryHandler to retrieve instances of the * type TY fulfilling the given Query. To start with, * we use a mock implementation. @@ -167,7 +167,7 @@ namespace lumiera * thus inheriting from the Handler classes for each type. In * the (future) version using YAP Prolog, this will drive the * generation and registration of the necessary predicate - * implementations for each concrete type, using the speicalisations + * implementations for each concrete type, using the specialisations * given alongside with the types. For now it just serves to generate * the necessary resolve(Query) virtual functions (implemented * by MockConfigRules) diff --git a/src/common/singletonsubclass.hpp b/src/common/singletonsubclass.hpp index a7e800487..48586f0f6 100644 --- a/src/common/singletonsubclass.hpp +++ b/src/common/singletonsubclass.hpp @@ -45,8 +45,8 @@ #include -namespace lumiera - { +namespace lumiera { + using boost::scoped_ptr; @@ -54,7 +54,7 @@ namespace lumiera { /** * Helper template to use the general policy classes of the lumiera::Singleton, - * but change the way they are parametrized on-the-fly. + * but change the way they are parametrised on-the-fly. */ template class POL, class I> struct Adapter @@ -63,7 +63,7 @@ namespace lumiera struct Link { virtual ~Link() {} - virtual I* create () = 0; ///< @note compiler will check the actual type is asignable... + virtual I* create () = 0; ///< @note compiler will check the actual type is assignable... virtual void destroy (I* pSi) = 0; }; @@ -73,14 +73,14 @@ namespace lumiera virtual S* create () { return POL::create (); } // covariance checked! virtual void destroy (I* pSi) { POL::destroy (static_cast (pSi)); } }; - - + + struct My_scoped_ptr : scoped_ptr ///< implementation detail: defeat static initialisation { using scoped_ptr::get; My_scoped_ptr() : scoped_ptr (get()? get() : 0) {} ///< bypass if already configured }; - + /** we configure this link \e later, when the singleton factory * is actually created, to point at the desired implementation subclass. */ @@ -94,9 +94,9 @@ namespace lumiera static void destroy (II* pSi) { link->destroy (pSi); } }; }; - + template class A, class I> - typename Adapter::My_scoped_ptr Adapter::link; // note: use special ctor (due to stati init order!) + typename Adapter::My_scoped_ptr Adapter::link; // note: use special ctor (due to static init order!) /** type-information used to configure the factory instance @@ -115,7 +115,7 @@ namespace lumiera * a subclass or wrap the product in some way. For the user code, it should behave * exactly like the standard SingletonFactory. The configuration of the product * actually to be created is delayed until the ctor call, so it can be hidden - * away to the implementaton of a class using the SingletonFactory. + * away to the implementation of a class using the SingletonFactory. * * @see configrules.cpp usage example */ @@ -134,10 +134,10 @@ namespace lumiera { public: /** The singleton-factory ctor configures what concrete type to create. - * It takes type information passed as dummy parameter and installes + * It takes type information passed as dummy parameter and installs * a trampoline object in the static field of class Adapter to perform * the necessary up/downcasts. This allows to use whatever policy - * class ist wanted, but parametrizes this policy template with + * class is desired, but parametrises this policy template with * the concrete type to be created. (only the "create" policy * needs to know the actual class, because it allocates storage) */ @@ -156,11 +156,11 @@ namespace lumiera "If using several instances of the sub-class-creating " "singleton factory, all *must* be configured to create " "objects of exactly the same implementation type!"); -#endif +#endif } }; - - + + /** * Default Singleton configuration (subclass creating factory) * @note all Policy template parameters taking default values diff --git a/src/gui/guinotificationfacade.cpp b/src/gui/guinotificationfacade.cpp new file mode 100644 index 000000000..90b8c6b1b --- /dev/null +++ b/src/gui/guinotificationfacade.cpp @@ -0,0 +1,56 @@ +/* + GuiNotificationFacade - access point for pushing informations into the GUI + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "include/guinotificationfacade.h" +#include "common/singleton.hpp" +#include "include/nobugcfg.h" +#include "common/util.hpp" + +#include + + +namespace gui { + + using std::string; + using util::cStr; + + class GuiNotificationFacade + : public GuiNotification + { + void + displayInfo (string const& text) + { + INFO (operate, "GUI: display '%s' as notification message.", cStr(text)); + } + + void + triggerGuiShutdown (string const& cause) + { + NOTICE (operate, "GUI: shutdown triggered with explanation '%s'....", cStr(cause)); + } + }; + + +//////////////////////////////////////////////TODO: define an instance lumieraorg_guinotification_facade by forwarding to GuiNotificationFacade + +} // namespace gui diff --git a/src/include/guinotificationfacade.h b/src/include/guinotificationfacade.h new file mode 100644 index 000000000..98aa56714 --- /dev/null +++ b/src/include/guinotificationfacade.h @@ -0,0 +1,85 @@ +/* + GUINOTIFICATIONFACADE.hpp - access point for pushing informations into the GUI + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file guifacade.hpp + ** Interface for the GUI loader and for accessing the GUI interface from the + ** lower layers of Lumiera. While part of the public interface of the Lumiera GUI, + ** the implementation of this facility is part of the core application (and not + ** contained within the GUI dynamic module), because it's job is to load and + ** activate this module and to startup the GUI. + ** + ** @see lumiera::AppState + ** @see lumiera::Option + ** @see guifacade.cpp + ** @see main.cpp + */ + + +#ifndef GUI_FACADE_H +#define GUI_FACADE_H + + +#include "common/singletonsubclass.hpp" + +#include + + +namespace gui { + + using std::string; + + + /********************************************************************* + * Global access point pushing state update and notification of events + * from the lower layers into the Lumiera GUI. Typically, this happens + * asynchronously and triggered by events within the lower layers. + * + */ + class GuiNotification + { + public: + static lumiera::SingletonSub facade; + + virtual void displayInfo (string const& text) =0; + + virtual void triggerGuiShutdown (string const& cause) =0; + + protected: + virtual ~GuiNotification() {} + }; + + + +} // namespace gui + +extern "C" { +#include "lumiera/interface.h" + +LUMIERA_INTERFACE_DECLARE (lumieraorg_guinotification, 0, + LUMIERA_INTERFACE_SLOT (void, displayInfo, (const char*)), + LUMIERA_INTERFACE_SLOT (void, triggerGuiShutdown, (const char*)), +); + + +} + +#endif diff --git a/src/lumiera/guifacade.cpp b/src/lumiera/guifacade.cpp index 237e87875..4c95638d0 100644 --- a/src/lumiera/guifacade.cpp +++ b/src/lumiera/guifacade.cpp @@ -30,10 +30,9 @@ namespace gui { using std::string; - using lumiera::Subsys; class GuiSubsysDescriptor - : public Subsys + : public lumiera::Subsys { operator string () const { return "Lumiera GTK GUI"; } @@ -59,13 +58,15 @@ namespace gui { }; - static lumiera::Singleton theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! + namespace { + lumiera::Singleton theDescriptor; + } /** @internal intended for use by main(). */ - Subsys& + lumiera::Subsys& GuiFacade::getDescriptor() { return theDescriptor(); diff --git a/src/lumiera/interfaceproxy.cpp b/src/lumiera/interfaceproxy.cpp new file mode 100644 index 000000000..579279318 --- /dev/null +++ b/src/lumiera/interfaceproxy.cpp @@ -0,0 +1,83 @@ +/* + InterfaceProxy - definition of forwarding proxies for the facade interfaces + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "common/singletonsubclass.hpp" +#include "include/guinotificationfacade.h" +#include "common/util.hpp" +#include "include/error.hpp" + +extern "C" { +#include "lumiera/interface.h" +} + +using util::cStr; + + +namespace singleton = lumiera::singleton; + +namespace gui { + + class GuiNotificationInterfaceProxy + : public GuiNotification + { + LUMIERA_INTERFACE_HANDLE(lumieraorg_guinotification, 0) interface_; + + GuiNotificationInterfaceProxy () + { + interface_ = LUMIERA_INTERFACE_OPEN (lumieraorg_guinotification, 0, 0, lumieraorg_guinotification_facade); + if (!interface_) + throw lumiera::error::State ("unable to access GuiNotificationFacade"); + } + + friend class singleton::StaticCreate; + + + + /* ======== forwarding through interface ========== */ + + void + displayInfo (string const& text) + { + interface_->displayInfo (cStr(text)); + } + + void + triggerGuiShutdown (string const& cause) + { + interface_->triggerGuiShutdown (cStr(cause)); + } + + + }; + + namespace { + + singleton::UseSubclass typeinfo_proxyInstance_to_create; + } + + /** storage for the facade proxy factory used by client code to invoke through the interface */ + lumiera::SingletonSub GuiNotification::facade (typeinfo_proxyInstance_to_create); + + + +} // namespace gui diff --git a/src/proc/facade.cpp b/src/proc/facade.cpp index d03d57d76..1d7d68b80 100644 --- a/src/proc/facade.cpp +++ b/src/proc/facade.cpp @@ -89,8 +89,10 @@ namespace proc { }; - static lumiera::Singleton theBuilderDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! - static lumiera::Singleton theSessionDescriptor; //////////////////TODO: work out startup sequence. Don't use static init! + namespace { + lumiera::Singleton theBuilderDescriptor; + lumiera::Singleton theSessionDescriptor; + } diff --git a/tests/common/singletonsubclasstest.cpp b/tests/common/singletonsubclasstest.cpp index cdbdd6934..ac3cbd3f0 100644 --- a/tests/common/singletonsubclasstest.cpp +++ b/tests/common/singletonsubclasstest.cpp @@ -83,7 +83,7 @@ namespace lumiera /******************************************************************* - * @test spezialized variant of the Singleton Factory, for creating + * @test specialised variant of the Singleton Factory, for creating * subclasses (implementation classes) without coupling the * caller to the concrete class type. * Expected results: an instance of the subclass is created. @@ -106,7 +106,7 @@ namespace lumiera singleton::UseSubclass typeinfo; // define an instance of the Singleton factory, - // spezialized to create the concrete Type passed in + // Specialised to create the concrete Type passed in SingletonSubclassFactory instance (typeinfo); // Now use the Singleton factory...