how to pass a render configuration strategy when creating a new play process

This commit is contained in:
Fischlurch 2011-12-17 22:37:53 +01:00
parent 6852a6feff
commit c4bc53b6f6
6 changed files with 53 additions and 26 deletions

View file

@ -58,7 +58,7 @@ namespace play {
* The caller gets to own and manage the returned process entry.
*/
PlayProcess*
PlayProcess::initiate (ModelPorts dataGenerators, RenderConfigurator& activeOutputFeedBuilder)
PlayProcess::initiate (ModelPorts dataGenerators, function<Feed(ModelPort)> activeOutputFeedBuilder)
{
return new PlayProcess (transform (dataGenerators,
activeOutputFeedBuilder));

View file

@ -63,6 +63,7 @@
//
#include <boost/noncopyable.hpp>
//#include <boost/scoped_ptr.hpp>
#include <tr1/functional>
//#include <string>
#include <vector>
@ -76,14 +77,13 @@ namespace play {
// using lumiera::DummyPlayer;
using util::isnil;
using proc::mobject::ModelPort;
using std::tr1::function;
typedef lib::IterSource<ModelPort>::iterator ModelPorts;
namespace error = lumiera::error;
/** Strategy for configuring the render process */
class RenderConfigurator;
/**
@ -132,7 +132,7 @@ namespace play {
public:
static PlayProcess*
initiate (ModelPorts dataGenerators, RenderConfigurator&);
initiate (ModelPorts dataGenerators, function<Feed(ModelPort)>);
};

View file

@ -26,12 +26,13 @@
#include "proc/play/play-service.hpp"
#include "proc/play/play-process.hpp"
#include "proc/play/render-configurator.hpp"
#include "proc/play/output-manager.hpp"
#include "lib/util-foreach.hpp"
#include <string>
//#include <memory>
//#include <tr1/functional>
////#include <tr1/functional>
#include <tr1/memory>
//#include <boost/scoped_ptr.hpp>
@ -176,22 +177,18 @@ namespace play {
* calculated media data to the outputs.
*/
Play::Controller
PlayService::connect (ModelPorts dataGenerators, Output outputDestinations)
PlayService::connect (ModelPorts dataGenerators, POutputManager outputPossibilities)
{
Timings playbackTimings; /////////////////////////////////////////////////////////////TODO
return pTable_->establishProcess(
PlayProcess::initiate(dataGenerators,
buildRenderConfiguration(outputDestinations)));
buildRenderConfiguration(outputPossibilities, playbackTimings)));
}
/** */
RenderConfigurator&
PlayService::buildRenderConfiguration (Output outputDestinations)
{
UNIMPLEMENTED ("how to build a suitable render configuration");
}

View file

@ -107,9 +107,7 @@ namespace play {
/** Implementation: build a PlayProcess */
virtual Controller connect(ModelPorts, Output);
RenderConfigurator& buildRenderConfiguration(Output);
virtual Controller connect(ModelPorts, POutputManager);
public:

View file

@ -29,6 +29,7 @@
//#include <string>
//#include <memory>
#include <tr1/memory>
#include <tr1/functional>
//#include <boost/scoped_ptr.hpp>
@ -42,6 +43,7 @@ namespace play {
// using lumiera::Subsys;
// using std::auto_ptr;
// using boost::scoped_ptr;
using std::tr1::shared_ptr;
using std::tr1::bind;
using std::tr1::placeholders::_1;
using engine::EngineService;
@ -49,6 +51,10 @@ namespace play {
typedef EngineService::QoS_Definition RenderQuality;
RenderConfigurator::~RenderConfigurator() { } // emit VTable here...
/** Template Method: how to build an active render feed,
* pulling from the given exit point of the model and
@ -62,9 +68,6 @@ namespace play {
}
RenderConfigurator::RenderConfigurator()
: function<Feed(ModelPort)> (bind (&RenderConfigurator::buildActiveFeed, this, _1))
{ }
@ -124,7 +127,27 @@ namespace play {
/** */
/** @internal this builder function is used by the PlayService
* when it comes to creating a new PlayProcess. The generated RenderConfigurator
* 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.
* @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
* later on be used to transform each desired model port
* into a suitable output connection, where the actual
* output will be resolved through the given
* OutputManager
*/
RenderConfigurator::ConnectFunction
buildRenderConfiguration (POutputManager outputPossibilities, Timings playbackTimings)
{
shared_ptr<RenderConfigurator> specialConfig (new DefaultRenderProcessBuilder (outputPossibilities, playbackTimings));
return bind (&RenderConfigurator::buildActiveFeed, specialConfig, _1 );
}
}} // namespace proc::play

View file

@ -43,11 +43,11 @@
#include "proc/play/play-process.hpp"
#include "proc/engine/calc-stream.hpp"
#include "proc/play/output-slot.hpp"
//#include "proc/play/output-manager.hpp"
#include "proc/play/output-manager.hpp"
//#include "lib/iter-source.hpp"
//#include "lib/util.hpp"
//
//#include <boost/noncopyable.hpp>
#include <boost/noncopyable.hpp>
//#include <boost/scoped_ptr.hpp>
//#include <string>
#include <tr1/functional>
@ -73,18 +73,17 @@ namespace play {
/** Strategy for configuring the render process */
class RenderConfigurator
: public function<Feed(ModelPort)>
: boost::noncopyable
{
public:
virtual ~RenderConfigurator(); ///< this is an interface
private:
Feed buildActiveFeed (ModelPort);
protected:
RenderConfigurator();
typedef function<Feed(ModelPort)> ConnectFunction;
protected:
/** retrieve a suitable output sink for the data
* to be produced at the given model exit point.
* While the port already defines the necessary StreamType,
@ -107,6 +106,16 @@ namespace play {
virtual engine::CalcStreams buildCalculationStreams (ModelPort, OutputSlot&) =0;
};
/** Factory function to build a RenderConfigurator
* specifically tailored for a given PlayProcess.
* @return the public access point to an RenderConfigurator,
* wrapped as generic function object
*/
RenderConfigurator::ConnectFunction
buildRenderConfiguration (POutputManager outputPossibilities, Timings playbackTimings);