first rough draft implementation of calling through a layer separation interface

This commit is contained in:
Fischlurch 2008-12-05 11:07:01 +01:00 committed by Christian Thaeter
parent 07d31fe772
commit 8c501a3d7c
12 changed files with 267 additions and 34 deletions

View file

@ -59,7 +59,9 @@ namespace backend {
};
static lumiera::Singleton<EngineSubsysDescriptor> theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
namespace {
lumiera::Singleton<EngineSubsysDescriptor> theDescriptor;
}

View file

@ -58,7 +58,9 @@ namespace backend {
};
static lumiera::Singleton<NetNodeSubsysDescriptor> theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
namespace {
lumiera::Singleton<NetNodeSubsysDescriptor> theDescriptor;
}

View file

@ -59,7 +59,9 @@ namespace backend {
};
static lumiera::Singleton<ScriptRunnerSubsysDescriptor> theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
namespace {
lumiera::Singleton<ScriptRunnerSubsysDescriptor> theDescriptor;
}

View file

@ -40,14 +40,14 @@ namespace lumiera
} // namespace query
namespace
{
namespace {
/** type of the actual ConfigRules implementation to use */
singleton::UseSubclass<query::MockConfigRules> typeinfo;
}
/** Singleton factory instance, parametrized to actual impl. type. */
/** Singleton factory instance, parametrised to actual impl. type. */
SingletonSub<ConfigRules> ConfigRules::instance (typeinfo);

View file

@ -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<TY>) virtual functions (implemented
* by MockConfigRules)

View file

@ -45,8 +45,8 @@
#include <typeinfo>
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<template<class> 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<S>::create (); } // covariance checked!
virtual void destroy (I* pSi) { POL<S>::destroy (static_cast<S*> (pSi)); }
};
struct My_scoped_ptr : scoped_ptr<Link> ///< implementation detail: defeat static initialisation
{
using scoped_ptr<Link>::get;
My_scoped_ptr() : scoped_ptr<Link> (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<template<class> class A, class I>
typename Adapter<A,I>::My_scoped_ptr Adapter<A,I>::link; // note: use special ctor (due to stati init order!)
typename Adapter<A,I>::My_scoped_ptr Adapter<A,I>::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

View file

@ -0,0 +1,56 @@
/*
GuiNotificationFacade - access point for pushing informations into the GUI
Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de>
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 <string>
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

View file

@ -0,0 +1,85 @@
/*
GUINOTIFICATIONFACADE.hpp - access point for pushing informations into the GUI
Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de>
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 <string>
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<GuiNotification> 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

View file

@ -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<GuiSubsysDescriptor> theDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
namespace {
lumiera::Singleton<GuiSubsysDescriptor> theDescriptor;
}
/** @internal intended for use by main(). */
Subsys&
lumiera::Subsys&
GuiFacade::getDescriptor()
{
return theDescriptor();

View file

@ -0,0 +1,83 @@
/*
InterfaceProxy - definition of forwarding proxies for the facade interfaces
Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de>
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<GuiNotificationInterfaceProxy>;
/* ======== forwarding through interface ========== */
void
displayInfo (string const& text)
{
interface_->displayInfo (cStr(text));
}
void
triggerGuiShutdown (string const& cause)
{
interface_->triggerGuiShutdown (cStr(cause));
}
};
namespace {
singleton::UseSubclass<GuiNotificationInterfaceProxy> typeinfo_proxyInstance_to_create;
}
/** storage for the facade proxy factory used by client code to invoke through the interface */
lumiera::SingletonSub<GuiNotification> GuiNotification::facade (typeinfo_proxyInstance_to_create);
} // namespace gui

View file

@ -89,8 +89,10 @@ namespace proc {
};
static lumiera::Singleton<BuilderSubsysDescriptor> theBuilderDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
static lumiera::Singleton<BuilderSubsysDescriptor> theSessionDescriptor; //////////////////TODO: work out startup sequence. Don't use static init!
namespace {
lumiera::Singleton<BuilderSubsysDescriptor> theBuilderDescriptor;
lumiera::Singleton<BuilderSubsysDescriptor> theSessionDescriptor;
}

View file

@ -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<Impl> 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<Interface> instance (typeinfo);
// Now use the Singleton factory...