test setup: simulated build proecss results, mock model port

This commit is contained in:
Fischlurch 2012-02-20 01:13:53 +01:00
parent f8f011bb44
commit 393a447861

View file

@ -81,11 +81,20 @@
#include "proc/play/output-manager.hpp"
#include "proc/mobject/model-port.hpp"
#include "lib/time/timequant.hpp"
//#include "lib/scoped-collection.hpp"
#include "proc/mobject/builder/model-port-registry.hpp"
#include "proc/asset/timeline.hpp"
#include "proc/asset/pipe.hpp"
#include "lib/query.hpp"
#include "lib/util.hpp"
//#include "lib/symbol.hpp"
#include "lib/iter-source.hpp"
//
#include <boost/noncopyable.hpp>
//#include <boost/scoped_ptr.hpp>
//#include <string>
#include <vector>
namespace proc {
@ -97,7 +106,7 @@ namespace play {
// using lumiera::DummyPlayer;
using lib::time::Duration;
typedef lib::IterSource<proc::mobject::ModelPort>::iterator ModelPorts;
typedef lib::IterSource<mobject::ModelPort>::iterator ModelPorts;
struct PlayTestFrames_Strategy
@ -106,6 +115,101 @@ namespace play {
};
namespace { // simulated builder environment
using asset::Pipe;
using asset::PPipe;
using asset::Struct;
using asset::Timeline;
using asset::PTimeline;
using mobject::ModelPort;
using mobject::builder::ModelPortRegistry;
using lumiera::Query;
using util::contains;
// using lib::ScopedCollection;
// using lib::Literal;
using lib::eachEntry;
typedef asset::ID<Pipe> PID;
typedef asset::ID<Struct> TID;
// typedef ModelPortRegistry::ModelPortDescriptor const& MPDescriptor;
inline PID
getPipe (string id)
{
return Pipe::query("id("+id+")");
}
inline TID
getTimeline (string id)
{
return asset::Struct::retrieve (Query<Timeline> ("id("+id+")"))->getID();
}
const uint NUMBER_OF_PORTS = 2;
const string namePortA("bus-A");
const string namePortB("bus-B");
/**
* helper for dummy render engine:
* Simulate the result of a build process,
* without actually running the builder.
* Produces some mock pipes, model ports etc.
*/
struct SimulatedBuilderContext
{
ModelPortRegistry registry_;
ModelPortRegistry* existingRegistry_;
std::vector<ModelPort> modelPorts_;
/** setup */
SimulatedBuilderContext()
: registry_()
, existingRegistry_(ModelPortRegistry::setActiveInstance (registry_))
{
performMockBuild();
}
/** tear-down */
~SimulatedBuilderContext()
{
if (existingRegistry_)
ModelPortRegistry::setActiveInstance (*existingRegistry_);
else
ModelPortRegistry::shutdown();
}
void
performMockBuild()
{
PID pipeA = getPipe (namePortA);
PID pipeB = getPipe (namePortB);
TID someTimeline = getTimeline ("dummy_Timeline");
// start out with defining some new model ports......
registry_.definePort (pipeA, someTimeline);
registry_.definePort (pipeB, someTimeline);
registry_.commit();
// now "bus-A" and "bus-B" are known as model ports
modelPorts_.push_back (ModelPort(pipeA));
modelPorts_.push_back (ModelPort(pipeB));
}
ModelPorts
getAllModelPorts()
{
return eachEntry (modelPorts_.begin(), modelPorts_.end());
}
};
}
/********************************************************************
* Framework for dummy playback and rendering.
* A DummyPlayConnection provides a coherent set of placeholders,
@ -118,13 +222,14 @@ namespace play {
class DummyPlayConnection
: boost::noncopyable
{
SimulatedBuilderContext mockBuilder_;
public:
ModelPorts
provide_testModelPorts()
{
UNIMPLEMENTED ("provide a set of test model ports");
return mockBuilder_.getAllModelPorts();
}
POutputManager