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
This commit is contained in:
Fischlurch 2012-01-21 02:30:01 +01:00
parent a2bcedc31e
commit ec659b7141
7 changed files with 25 additions and 44 deletions

View file

@ -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<backend::MediaAccessFacade>
: public MockInjector<backend::MediaAccessFacade>
{ };
template<>
class Singleton<proc::engine::EngineService>
: public MockInjector<proc::engine::EngineService>
{ };
} // namespace lib

View file

@ -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
**

View file

@ -46,8 +46,6 @@ namespace engine{
/** storage for the EngineService interface object */
lib::Singleton<EngineServiceMock> EngineServiceMock::instance;

View file

@ -85,14 +85,12 @@ namespace engine{
* order and to enqueue these into the scheduler.
*/
class EngineServiceMock
: boost::noncopyable
: public EngineService
{
lib::ScopedPtrVect<node::DummyTick> processors_;
public:
/** access point to the Engine Interface Mock implementation. */
static lib::Singleton<EngineServiceMock> instance;
EngineServiceMock();
~EngineServiceMock() { }

View file

@ -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 <tr1/functional>
@ -49,6 +49,7 @@ namespace proc {
namespace node {
using std::tr1::function;
using std::tr1::bind;

View file

@ -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 <string>
@ -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);
}

View file

@ -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