refactor to simplify generating a PlayProcess

This commit is contained in:
Fischlurch 2011-12-18 02:02:55 +01:00
parent cedfa34074
commit fa0588b584
2 changed files with 24 additions and 23 deletions

View file

@ -28,7 +28,7 @@
//#include <string>
//#include <memory>
#include <tr1/functional>
//#include <tr1/functional>
//#include <boost/scoped_ptr.hpp>
@ -42,6 +42,7 @@ namespace play {
// using boost::scoped_ptr;
// using std::tr1::bind;
using lib::transform;
using lib::append_all;
namespace { // Implementation details...
@ -50,6 +51,13 @@ namespace play {
} // (End) hidden service impl details
PlayProcess::PlayProcess (OutputFeeds feeds)
: outputFeeds_(feeds)
{
if (isnil (feeds))
throw error::State ("creating a PlayProcess without any usable output connections"
, LUMIERA_ERROR_CANT_PLAY);
}
@ -58,27 +66,19 @@ namespace play {
* The caller gets to own and manage the returned process entry.
*/
PlayProcess*
PlayProcess::initiate (ModelPorts dataGenerators, function<Feed(ModelPort)> activeOutputFeedBuilder)
{
return new PlayProcess (transform (dataGenerators,
activeOutputFeedBuilder));
PlayProcess::initiate (ModelPorts dataGenerators, FeedBuilder activeOutputFeedBuilder)
{
OutputFeeds newFeeds;
append_all (transform (dataGenerators, activeOutputFeedBuilder), newFeeds);
return new PlayProcess (newFeeds);
/////////////////////////////////////////////////////////////////////////////////////////////TICKET #874 : use a pipeline builder to write it as follows:
// treat_all(dataGenerators)
// .apply (activeOutputFeedBuilder)
// .buildVector();
}
/** @internal actually create and configure a play process instance */
PlayProcess::PlayProcess (Connections pipeConnections)
{
if (isnil (pipeConnections))
throw error::State ("creating a PlayProcess without any usable output connections"
, LUMIERA_ERROR_CANT_PLAY);
UNIMPLEMENTED ("iterate over the connections and allocate/establish each of them, creating and storing Feed objects");
while (pipeConnections)
{
}
}
/** */

View file

@ -103,6 +103,9 @@ namespace play {
* here through the RenderConfigurator instance */
Feed (engine::CalcStreams const&);
};
typedef function<Feed(ModelPort)> FeedBuilder;
typedef std::vector<Feed> OutputFeeds;
/******************************************************
@ -124,15 +127,13 @@ namespace play {
class PlayProcess
: boost::noncopyable
{
std::vector<Feed> outputFeeds_;
OutputFeeds outputFeeds_;
typedef lib::IterSource<Feed>::iterator Connections;
PlayProcess (Connections pipeConnections);
PlayProcess (OutputFeeds feeds);
public:
static PlayProcess*
initiate (ModelPorts dataGenerators, function<Feed(ModelPort)>);
initiate (ModelPorts dataGenerators, FeedBuilder);
};