diff --git a/src/proc/engine/engine-service-mock.cpp b/src/proc/engine/engine-service-mock.cpp new file mode 100644 index 000000000..b47b1516b --- /dev/null +++ b/src/proc/engine/engine-service-mock.cpp @@ -0,0 +1,91 @@ +/* + EngineServiceMock - dummy render engine implementation for test/development + + Copyright (C) Lumiera.org + 2012, 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 "proc/engine/engine-service-mock.hpp" + +//#include +//#include +//#include +//#include + + + +namespace proc { +namespace engine{ + +// using std::string; +// using lumiera::Subsys; +// using std::auto_ptr; +// using boost::scoped_ptr; +// using std::tr1::bind; + + + namespace { // hidden local details of the service implementation.... + + } // (End) hidden service impl details + + + + /** storage for the EngineService interface object */ + lib::Singleton EngineServiceMock::instance; + + + + /** */ + EngineServiceMock::EngineServiceMock() + { } + + + + /** core operation: activate the Lumiera Render Engine. + * Invoking this service effectively hooks up each channel + * of the given model exit point to deliver into the corresponding + * output sink on the given OutputConnection (which is assumed + * to be already allocated for active use by this connection). + * The generated calculation streams represent actively ongoing + * calculations within the engine, started right away, according + * to the given timing constraints and service quality. + */ + CalcStreams + EngineServiceMock::calculate(ModelPort mPort, + Timings nominalTimings, + OutputConnection& output, + Quality serviceQuality) + { + UNIMPLEMENTED ("MOCK IMPLEMENTATION: build a list of standard calculation streams"); + } + + + + /** */ + CalcStreams + EngineServiceMock::calculateBackground(ModelPort mPort, + Timings nominalTimings, + Quality serviceQuality) + { + UNIMPLEMENTED ("MOCK IMPLEMENTATION: build calculation streams for background rendering"); + } + + + +}} // namespace proc::engine diff --git a/src/proc/engine/engine-service-mock.hpp b/src/proc/engine/engine-service-mock.hpp new file mode 100644 index 000000000..2d865d223 --- /dev/null +++ b/src/proc/engine/engine-service-mock.hpp @@ -0,0 +1,119 @@ +/* + ENGINE-SERVICE-MOCK.hpp - dummy render engine implementation for test/development + + Copyright (C) Lumiera.org + 2012, 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 engine-service-mock.hpp + ** Placeholder implementation of the render engine for test and diagnostics. + ** This implementation can be used as a drop-in replacement of the real engine. + ** Of course, it is lacking most of the functionality; it is just usable to detect + ** and verify the actual engine setup and invocation that \em would happen. + ** + ** @todo 1/2012 until the real render engine is usable, this mock implementation + ** will stand-in, allowing us to develop the other parts of the play/render subsystem. + ** + ** @see proc::engine::EngineService "the real thing" + ** @see render-configurator.cpp (activating the mock or the real engine) + ** @see DummyPlayConnection + ** @see EngineInterface_test + ** @see CalcStream_test + */ + + +#ifndef PROC_ENGINE_ENGINE_SERVICE_MOCK_H +#define PROC_ENGINE_ENGINE_SERVICE_MOCK_H + + +#include "lib/error.hpp" +//#include "include/dummy-player-facade.h" +//#include "include/display-facade.h" +#include "proc/engine/calc-stream.hpp" +#include "proc/mobject/model-port.hpp" +#include "proc/play/timings.hpp" +#include "proc/play/output-slot.hpp" +//#include "common/instancehandle.hpp" +//#include "lib/singleton-ref.hpp" +#include "proc/engine/engine-service.hpp" +#include "lib/singleton.hpp" +// +#include +//#include +//#include + + +namespace proc { +namespace engine{ + +// using std::string; +// using lumiera::Subsys; +// using lumiera::Display; +// using lumiera::DummyPlayer; + using mobject::ModelPort; + using proc::play::Timings; + + typedef EngineService::Quality Quality; + + + + + + /****************************************************** + * A service to schedule series of calculations, + * delivering the rendered data into an external output + * sink in a timely fashion. Actually the CalculationStream + * instances provided through this (facade) interface are + * backed by jobs executed through the scheduler in the + * backend layer. The implementation of this service + * cares to create the right job entries in the correct + * order and to enqueue these into the scheduler. + */ + class EngineServiceMock + : boost::noncopyable + { + + + public: + /** access point to the Engine Interface Mock implementation. */ + static lib::Singleton instance; + + + EngineServiceMock(); + ~EngineServiceMock() { } + + CalcStreams + calculate(ModelPort mPort, + Timings nominalTimings, + OutputConnection& output, + Quality serviceQuality = EngineService::QoS_DEFAULT); + + CalcStreams + calculateBackground(ModelPort mPort, + Timings nominalTimings, + Quality serviceQuality = EngineService::QoS_BACKGROUND); + + + protected: + }; + + + + +}} // namespace proc::engine +#endif diff --git a/src/proc/play/render-configurator.cpp b/src/proc/play/render-configurator.cpp index ebf9eef45..f5e1c4d4c 100644 --- a/src/proc/play/render-configurator.cpp +++ b/src/proc/play/render-configurator.cpp @@ -25,6 +25,7 @@ #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 @@ -47,6 +48,7 @@ namespace play { using std::tr1::bind; using std::tr1::placeholders::_1; using engine::EngineService; + using engine::EngineServiceMock; typedef EngineService::QoS_Definition RenderQuality; @@ -107,7 +109,14 @@ namespace play { Timings nominalTimings = activeOutputConnection.getTimingConstraints() .constrainedBy(playbackTimings_); - return EngineService::instance().calculate (port, nominalTimings, activeOutputConnection, renderQuality_); + return activateEngine (port, nominalTimings, activeOutputConnection, renderQuality_); + } + + protected: + virtual engine::CalcStreams + activateEngine (ModelPort port, Timings timings, OutputSlot::Allocation& activeOutputConnection, RenderQuality quality) + { + return EngineService::instance().calculate (port, timings, activeOutputConnection, quality); } @@ -119,6 +128,34 @@ 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 */ + inline RenderConfigurator* + how_to_render (POutputManager outputPossibilities, Timings playTimings) + { + if (playTimings.isMockEngineRun()) + return new MockRenderProcessBuilder (outputPossibilities, playTimings); + + else + return new LumieraRenderProcessBuilder (outputPossibilities, playTimings); + } } // (End) hidden service impl details @@ -129,9 +166,10 @@ namespace play { /** @internal this builder function is used by the PlayService * when it comes to creating a new PlayProcess. The generated ConnectFunction - * embodies the specific knowledge how to configure and setup the rendering or - * playback at the EngineFacade, based on the general playback speed and - * quality desirable for this playback process to be initiated. + * treats a single ModelPort to produce a suitable rendering setup, pulling data + * from this port; it thus embodies the specific knowledge how to configure and + * setup the rendering or playback at the EngineFacade, based on the playback + * speed and quality desirable for this playback process to be initiated. * @remarks building a special subclass here and managing this instance * by smart-ptr. Then wrapping all of this up into a functor, * which can thus be passed on by value. This functor will @@ -141,11 +179,9 @@ namespace play { * OutputManager */ RenderConfigurator::ConnectFunction - buildRenderConfiguration (POutputManager outputPossibilities, Timings playbackTimings) + buildRenderConfiguration (POutputManager outputPossibilities, Timings playTimings) { - /////////////////////////////////////////////TODO this is the point to inject a Dummy implementation or anything bypassing the Lumiera engine! - - shared_ptr specialConfig (new LumieraRenderProcessBuilder (outputPossibilities, playbackTimings)); + shared_ptr specialConfig (how_to_render (outputPossibilities,playTimings)); return bind (&RenderConfigurator::buildActiveFeed, specialConfig, _1 ); } diff --git a/src/proc/play/render-configurator.hpp b/src/proc/play/render-configurator.hpp index 44b44f171..4ba8cc665 100644 --- a/src/proc/play/render-configurator.hpp +++ b/src/proc/play/render-configurator.hpp @@ -109,7 +109,13 @@ namespace play { /** Factory function to build a RenderConfigurator - * specifically tailored for a given PlayProcess. + * specifically tailored for a PlayProcess, about to be started. + * @param outputPossibilities an OutputManager instance describing + * the situation where output is about to be generated (e.g. + * a viewer in the GUI or a file to be rendered) + * @param playbackTimings characterisation of the kind of play/render. + * Besides the required delivery interval, this might also define + * quality-of-service expectations. * @return the public access point to an RenderConfigurator, * wrapped as generic function object */ diff --git a/src/proc/play/timings.hpp b/src/proc/play/timings.hpp index 5c6963f17..649007979 100644 --- a/src/proc/play/timings.hpp +++ b/src/proc/play/timings.hpp @@ -70,8 +70,9 @@ namespace play { - /******************************************************************** - * Data-Record: Generic frame timing specification. + /***************************************************************************** + * Generic frame timing specification. Defines the expected delivery interval, + * optionally also the expected quality-of-service * * @note copyable value class * @@ -80,7 +81,16 @@ namespace play { class Timings { public: - //////////////TODO accessor functions here + /** 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 Timings constrainedBy (Timings additionalConditions)