diff --git a/src/common/interfaceproxy.cpp b/src/common/interfaceproxy.cpp index 0aff8f5cd..dd4674dcd 100644 --- a/src/common/interfaceproxy.cpp +++ b/src/common/interfaceproxy.cpp @@ -22,70 +22,24 @@ #include "include/interfaceproxy.hpp" -#include "lib/singletonsubclass.hpp" ////////////////////TODO -#include "include/guinotificationfacade.h" -#include "lib/util.hpp" +#include "common/instancehandle.hpp" #include "lib/error.hpp" - -extern "C" { -#include "common/interface.h" -} +#include "lib/util.hpp" using util::cStr; -namespace singleton = lumiera::singleton; +#include "include/guinotificationfacade.h" namespace gui { - - class GuiNotificationInterfaceProxy - : public GuiNotification - { - LUMIERA_INTERFACE_INAME(lumieraorg_GuiNotification, 1) * interface_; - - GuiNotificationInterfaceProxy () - { - interface_ = LUMIERA_INTERFACE_OPEN (lumieraorg_GuiNotification, 1, 2, lumieraorg_GuiNotificationFacade); - 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); - - ///////////////////////////////////////TODO: this solution is not correct, because it doesn't detect when the interface is shut down! - - + lumiera::facade::Accessor GuiNotification::facade; } // namespace gui -#include "common/instancehandle.hpp" + + namespace lumiera { namespace facade { @@ -105,6 +59,13 @@ namespace lumiera { typedef Proxy Proxy; typedef Accessor Access; + I& _i_; + + Holder (IHandle& iha) + : _i_(iha.get()) + { } + + public: static Proxy& open(IHandle& iha) { static char buff[sizeof(Proxy)]; @@ -120,14 +81,6 @@ namespace lumiera { Access::implProxy_ = 0; p->~Proxy(); } - - - I& _i_; - - Holder (IHandle& iha) - : _i_(iha.get()) - { } - }; @@ -135,36 +88,6 @@ namespace lumiera { FA* Accessor::implProxy_; - struct XYZ - { - virtual ~XYZ(){} - - virtual int zoing(int i) =0; - }; - - struct II {}; - - typedef InstanceHandle IIXYZ; - - - template<> - class Proxy - : public Holder - { - //----Proxy-Implementation-of-XYZ-------- - - virtual int - zoing (int i) - { - return (rand() % i); - } - - - public: - Proxy (IHandle iha) : THolder(iha) {} - }; - - template void openProxy (IHA& iha) @@ -174,12 +97,39 @@ namespace lumiera { template void - closeProxy (IHA& iha) + closeProxy (IHA&) { Proxy::close(); } + + typedef InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_GuiNotification, 1) + , gui::GuiNotification + > Handle_GuiNotification; + + + template<> + class Proxy + : public Holder + { + //----Proxy-Implementation-of-GuiNotification-------- + + void displayInfo (string const& text) { _i_.displayInfo (cStr(text)); } + void triggerGuiShutdown (string const& cause) { _i_.triggerGuiShutdown (cStr(cause)); } + + + public: + Proxy (IHandle& iha) : THolder(iha) {} + }; + + + + + template void openProxy (Handle_GuiNotification&); + template void closeProxy (Handle_GuiNotification&); + + } // namespace facade } // namespace lumiera diff --git a/src/include/guinotificationfacade.h b/src/include/guinotificationfacade.h index 916f0ddc4..648839f50 100644 --- a/src/include/guinotificationfacade.h +++ b/src/include/guinotificationfacade.h @@ -40,7 +40,7 @@ #ifdef __cplusplus /* ============== C++ Interface ================= */ -#include "lib/singletonsubclass.hpp" +#include "include/interfaceproxy.hpp" #include @@ -63,7 +63,7 @@ namespace gui { class GuiNotification { public: - static lumiera::SingletonSub facade; + static lumiera::facade::Accessor facade; /** push a user visible notification text */ virtual void displayInfo (string const& text) =0;