diff --git a/src/proc/engine/nodefactory.cpp b/src/proc/engine/nodefactory.cpp index 9d5169d92..628e247e2 100644 --- a/src/proc/engine/nodefactory.cpp +++ b/src/proc/engine/nodefactory.cpp @@ -24,12 +24,58 @@ #include "proc/engine/nodefactory.hpp" #include "proc/mobject/session/effect.hpp" -namespace engine { +#include "proc/engine/nodewiring.hpp" +namespace engine { + + namespace { // Details of node fabrication + + class Alloc {}; ///////////////TODO + + template + NODE & + makeNode () + { + ////TODO: this is a draft how it /might/ work + ////TODO: of course this can't be hard wired.... + + ProcNode * predecessor1, predecessor2; + + WiringInstaller setup; + setup.defineInput (4, predecessor1, 2); + setup.defineInput (2, predecessor2); + + WiringFactory* wFac; + + Alloc allocator; + bool doCache = (2 == 2); // find out Cache should be used for this node + + WiringDescriptor & wDesc = (*wFac)(setup,doCache); + + NODE *newNode = new(allocator()) NODE (wDesc); // actually this line needs to be atomic + + return *newNode; + + /* + * Problems to be solved: + * - write a generic allocator, which later on can be augmented to do block wise bulk allocation + * - the allocator needs to keep track of the objects; actually he owns the objects + * - we need to access the wiring descriptor of the predecessor nodes. Which means, the code + * must be in the body of NodeFactory (because the latter is friend of ProcNode and can access the wiring descriptor) + * - btw reconsider if this level of protection is necessary, or if the const WiringDescriptor cant be just on the public interface of ProcNode + * - find out how the Caching/ReadInput/InPlace detection can work + * - think about a sensible Ctor for NodeFactory. This one must create the WiringFactory and pass the Allocator. + * - all of this will be installed into the ToolFactory, i.e. it is part of the build process + */ + } + + } // (END) Details of node fabrication + + using mobject::Placement; using mobject::session::Effect; - + /** create a processing node able to render an effect */ PTrafo NodeFactory::operator() (Placement const&) diff --git a/src/proc/engine/nodewiring.cpp b/src/proc/engine/nodewiring.cpp index 864905a22..ccb0824a3 100644 --- a/src/proc/engine/nodewiring.cpp +++ b/src/proc/engine/nodewiring.cpp @@ -119,7 +119,7 @@ namespace engine { * the new processing node to be wired up. */ WiringDescriptor& - WiringFactory::operator() (uint nrOut, uint nrIn, bool cache) + WiringFactory::operator() (WiringInstaller& setup, bool cache) { UNIMPLEMENTED ("build the actual wiring descriptor based on given operation options"); diff --git a/src/proc/engine/nodewiring.hpp b/src/proc/engine/nodewiring.hpp index 661cb7c46..c906e7329 100644 --- a/src/proc/engine/nodewiring.hpp +++ b/src/proc/engine/nodewiring.hpp @@ -27,6 +27,7 @@ #include "proc/engine/procnode.hpp" +#include #include #include @@ -39,6 +40,28 @@ namespace engine { namespace config { class WiringFactoryImpl; } + using lib::RefArray; + + + /** + * Finding out about a concrete way of wiring up a + * ProcNode about to be built. Such a (temporary) setup object + * is used while building the low-level model. It is loaded with + * information concerning the intended connections to be made + * and then used to initialise the wiring descriptor, which + * in turn allows us to setup the ProcNode. + */ + class WiringInstaller : boost::noncopyable + { + public: + RefArray& makeOutDescriptor() ; + RefArray& makeInDescriptor() ; + WiringDescriptor::ProcFunc* resolveProcessingFunction() ; + lumiera::NodeID const& createNodeID() ; + }; + + + /** * Actual implementation of the link between nodes, @@ -54,6 +77,16 @@ namespace engine { : public WiringDescriptor { + NodeWiring(WiringInstaller& setup) + : WiringDescriptor(setup.makeOutDescriptor(), + setup.makeInDescriptor(), + setup.resolveProcessingFunction(), + setup.createNodeID()) + { + nrO = out.size(); + nrI = in.size(); + } + friend class WiringFactory; @@ -65,10 +98,6 @@ namespace engine { return thisStep.retrieve (); // fetch or calculate results } - - ////// - //////TODO: push "almost everything" up into an ABC - ////////// and create an ctor to set up the RefArrays }; @@ -79,7 +108,7 @@ namespace engine { public: WiringDescriptor& - operator() (uint nrOut, uint nrIn, bool cache); + operator() (WiringInstaller& setup, bool cache); }; diff --git a/src/proc/engine/procnode.hpp b/src/proc/engine/procnode.hpp index 0b4d218d0..05bfaf8e9 100644 --- a/src/proc/engine/procnode.hpp +++ b/src/proc/engine/procnode.hpp @@ -46,6 +46,7 @@ #include "proc/state.hpp" #include "proc/mobject/parameter.hpp" #include "common/frameid.hpp" +#include "lib/refarray.hpp" #include @@ -58,8 +59,6 @@ namespace engine { using lumiera::NodeID; class ProcNode; - class NodeFactory; - typedef ProcNode* PNode; @@ -70,11 +69,11 @@ namespace engine { class WiringDescriptor { public: - uint nrI; uint nrO; + uint nrI; - ChannelDescriptor out[]; - InChanDescriptor in[]; + lib::RefArray& out; + lib::RefArray& in; typedef void (ProcFunc) (BuffHandle::PBuff); @@ -85,8 +84,8 @@ namespace engine { virtual ~WiringDescriptor() {} protected: - WiringDescriptor (ChannelDescriptor* o, - InChanDescriptor* i, + WiringDescriptor (lib::RefArray& o, + lib::RefArray& i, ProcFunc pFunc, NodeID const& nID) : out(o), in(i), procFunction(pFunc),