From ec659b714130d5729082f318a259fb0e4fa8fb2b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 21 Jan 2012 02:30:01 +0100 Subject: [PATCH] a better way to inject the Render-Engine Mock instead of (ab)using the Timings spect for a runtime switch, better use the existing MockInjector facility and thus turn the mock engine mode into a global switch --- src/lib/singleton-preconfigure.hpp | 14 ++++++++++++- src/lib/singleton.hpp | 4 ++-- src/proc/engine/engine-service-mock.cpp | 2 -- src/proc/engine/engine-service-mock.hpp | 6 ++---- src/proc/engine/worker/tick-service.hpp | 9 +++++---- src/proc/play/render-configurator.cpp | 26 +++---------------------- src/proc/play/timings.hpp | 8 -------- 7 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/lib/singleton-preconfigure.hpp b/src/lib/singleton-preconfigure.hpp index faca11e86..32973ad90 100644 --- a/src/lib/singleton-preconfigure.hpp +++ b/src/lib/singleton-preconfigure.hpp @@ -75,7 +75,13 @@ namespace backend { class MediaAccessFacade; using lib::Singleton; -} // namespace backend_interface +} // namespace backend + +namespace proc { +namespace engine { + class EngineService; + using lib::Singleton; +}} @@ -100,6 +106,12 @@ namespace lib { class Singleton : public MockInjector { }; + + + template<> + class Singleton + : public MockInjector + { }; } // namespace lib diff --git a/src/lib/singleton.hpp b/src/lib/singleton.hpp index f7af5ddba..33ccd9fa1 100644 --- a/src/lib/singleton.hpp +++ b/src/lib/singleton.hpp @@ -25,10 +25,10 @@ ** This configuration header just pulls in some other implementation headers in ** the right order. The basic class template for creating singletons resides in ** singleton-factory.hpp, besides we need policy classes defining how to create - ** the singleton objects and how to manage singleton lifecycle. Finally, + ** the singleton objects and how to manage singleton lifecycle. Finally, ** we want to preconfigure singleton factories for some important facilities; ** e.g. sometimes we want to include a hook for injecting Test Mock instances. - ** + ** ** You'll find the default Policies in singleton-factory.hpp and the default ** definition of type lumiera::singleton in singleton-preconfigure.hpp ** diff --git a/src/proc/engine/engine-service-mock.cpp b/src/proc/engine/engine-service-mock.cpp index b47b1516b..f72e8598b 100644 --- a/src/proc/engine/engine-service-mock.cpp +++ b/src/proc/engine/engine-service-mock.cpp @@ -46,8 +46,6 @@ namespace engine{ - /** storage for the EngineService interface object */ - lib::Singleton EngineServiceMock::instance; diff --git a/src/proc/engine/engine-service-mock.hpp b/src/proc/engine/engine-service-mock.hpp index 2d865d223..ce4fec5e2 100644 --- a/src/proc/engine/engine-service-mock.hpp +++ b/src/proc/engine/engine-service-mock.hpp @@ -85,14 +85,12 @@ namespace engine{ * order and to enqueue these into the scheduler. */ class EngineServiceMock - : boost::noncopyable + : public EngineService { + lib::ScopedPtrVect processors_; public: - /** access point to the Engine Interface Mock implementation. */ - static lib::Singleton instance; - EngineServiceMock(); ~EngineServiceMock() { } diff --git a/src/proc/engine/worker/tick-service.hpp b/src/proc/engine/worker/tick-service.hpp index 3f93dee56..1237727e3 100644 --- a/src/proc/engine/worker/tick-service.hpp +++ b/src/proc/engine/worker/tick-service.hpp @@ -25,10 +25,9 @@ ** A timer service invoking a given callback periodically. ** This is a rough preliminary implementation as of 1/2009. We use it to ** drive the frame "creation" of a player dummy (the render engine is not - ** ready yet). The intention is to make this a real service later on, which - ** might consolidate and sync various ongoing output processes to a common - ** beat, which it implements by precision posix timers. Probably then this - ** service will become part of the backend, or rely on a timing service. + ** ready yet). The intention is to use this service as part of a mock engine + ** setup, used to verify the construction of engine components. As an integration + ** test, we build a "dummy player", delivering some test data frames to the Gui. ** ** @see proc::play::DummyPlayerService ** @@ -39,6 +38,7 @@ #define PROC_PLAY_TICKSERVICE_H +#include "lib/error.hpp" #include "backend/thread-wrapper.hpp" #include @@ -49,6 +49,7 @@ namespace proc { namespace node { using std::tr1::function; + using std::tr1::bind; diff --git a/src/proc/play/render-configurator.cpp b/src/proc/play/render-configurator.cpp index f5e1c4d4c..ba378cae7 100644 --- a/src/proc/play/render-configurator.cpp +++ b/src/proc/play/render-configurator.cpp @@ -25,7 +25,6 @@ #include "proc/play/render-configurator.hpp" #include "proc/play/output-manager.hpp" #include "proc/engine/engine-service.hpp" -#include "proc/engine/engine-service-mock.hpp" //#include "lib/itertools.hpp" //#include @@ -48,7 +47,6 @@ namespace play { using std::tr1::bind; using std::tr1::placeholders::_1; using engine::EngineService; - using engine::EngineServiceMock; typedef EngineService::QoS_Definition RenderQuality; @@ -129,32 +127,14 @@ namespace play { }; - class MockRenderProcessBuilder - : public LumieraRenderProcessBuilder - { - engine::CalcStreams - activateEngine (ModelPort port, Timings timings, OutputSlot::Allocation& activeOutputConnection,RenderQuality quality) - { - return EngineServiceMock::instance().calculate (port, timings, activeOutputConnection, quality); - } - - public: - MockRenderProcessBuilder (POutputManager outputManager, Timings playbackSpeed) - : LumieraRenderProcessBuilder(outputManager,playbackSpeed) - { } - }; - - /** @internal decision point about how to configure the rendering */ + /** @internal decision point about how to configure the rendering. + * This would be the point to switch the render engine used. */ inline RenderConfigurator* how_to_render (POutputManager outputPossibilities, Timings playTimings) { - if (playTimings.isMockEngineRun()) - return new MockRenderProcessBuilder (outputPossibilities, playTimings); - - else - return new LumieraRenderProcessBuilder (outputPossibilities, playTimings); + return new LumieraRenderProcessBuilder (outputPossibilities, playTimings); } diff --git a/src/proc/play/timings.hpp b/src/proc/play/timings.hpp index 649007979..d40e23a54 100644 --- a/src/proc/play/timings.hpp +++ b/src/proc/play/timings.hpp @@ -81,14 +81,6 @@ namespace play { class Timings { public: - /** push aside the real Lumiera engine and use a test mock. - * @todo 1/2012 hard wired -- until the engine becomes usable - */ - bool - isMockEngineRun () - { - return true; - } //////////////TODO further accessor functions here