/* 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 "include/interfaceproxy.hpp" #include "common/instancehandle.hpp" #include "lib/error.hpp" #include "lib/util.hpp" using util::cStr; #include "include/guinotificationfacade.h" namespace gui { /** storage for the facade proxy factory used by client code to invoke through the interface */ lumiera::facade::Accessor GuiNotification::facade; } // namespace gui namespace lumiera { namespace facade { template class Holder; template class Holder > : Accessor, protected FA { protected: typedef InstanceHandle IHandle; typedef Holder THolder; 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)]; Proxy* p = new(buff) Proxy(iha); Access::implProxy_ = p; return *p; } static void close() { if (!Access::implProxy_) return; Proxy* p = static_cast (Access::implProxy_); Access::implProxy_ = 0; p->~Proxy(); } }; template FA* Accessor::implProxy_; template void openProxy (IHA& iha) { Proxy::open(iha); } template void 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