From 2a54f92a9815b63984c658c7fdc2037ca4e879fb Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 30 Aug 2009 14:50:40 +0200 Subject: [PATCH] WIP: implement creation of concrete wiring descriptor --- src/proc/engine/nodefactory.cpp | 2 +- src/proc/engine/nodewiring.cpp | 54 +++++++++++++++++++++------------ src/proc/engine/nodewiring.hpp | 10 ++++-- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/proc/engine/nodefactory.cpp b/src/proc/engine/nodefactory.cpp index 55ee297cc..abdbc4a01 100644 --- a/src/proc/engine/nodefactory.cpp +++ b/src/proc/engine/nodefactory.cpp @@ -42,7 +42,7 @@ namespace engine { ProcNode * predecessor1, predecessor2; - WiringInstaller setup; + WiringSituation setup; setup.defineInput (4, predecessor1, 2); setup.defineInput (2, predecessor2); diff --git a/src/proc/engine/nodewiring.cpp b/src/proc/engine/nodewiring.cpp index 551566acc..84e52c4be 100644 --- a/src/proc/engine/nodewiring.cpp +++ b/src/proc/engine/nodewiring.cpp @@ -25,7 +25,6 @@ #include "proc/engine/nodewiring.hpp" #include "proc/engine/nodeoperation.hpp" #include "proc/engine/nodewiring-config.hpp" -#include "lib/allocationcluster.hpp" #include "lib/meta/typelist-util.hpp" @@ -56,6 +55,12 @@ namespace engine { typedef Filter::Test> PossibleConfigs; + #define PICK_FLAG(_FLAG_) config::FlagInfo::CODE & (_FLAG_) + + template + struct UseBufferProvider + : config::SelectBuffProvider< PICK_FLAG (CACHING), PICK_FLAG (INPLACE) > + { }; // internal details: setting up a factory for each required configuration @@ -70,31 +75,32 @@ namespace engine { { AllocationCluster& alloc_; + /* ==== pick actual wiring code ==== */ + typedef Strategy Strategy; + typedef typename UseBufferProvider::Type BuffProvider; + typedef ActualInvocationProcess InvocationStateType; + + // the concrete implementation of the glue code... + typedef NodeWiring ActualWiring; + + public: WiringDescriptorFactory(AllocationCluster& a) : alloc_(a) {} WiringDescriptor& - operator() () + operator() (WiringSituation const& intendedWiring) { - /////////////////////////////////////////////TODO - - typedef config::Strategy Strategy; - typedef typename config::SelectBuffProvider<>::Type BuffProvider; ////////////////////////TODO: how to extract the required flags from CONF?? - typedef ActualInvocationProcess InvocationStateType; - - typedef NodeWiring Product; - - ///////////////////////////////////////////////////////////////////////////////TODO: how to get the WiringInstaller here???? - Product * dummy (0); - return *dummy; + return alloc_.create (intendedWiring); } }; - typedef WiringDescriptor& (FunctionType)(void); + /** invocation signature of the factories */ + typedef WiringDescriptor& (FunctionType)(WiringSituation const&); + /** preconfigured table of all possible factories */ typedef ConfigSelector< WiringDescriptorFactory ///< Factory template to instantiate - , FunctionType ///< function signature of the Factory + , FunctionType ///< function signature of the Factories , AllocationCluster& ///< allocator fed to all factories > WiringSelector; @@ -111,9 +117,20 @@ namespace engine { } // (END) internals (namespace config) - /////////////////////////////TODO: define the ctor + /** As the WiringFactory (an all the embedded factories + * for the specific wiring situations) use the AllocationCluster + * of the current build process, we need to create a new instance + * for each newly built segment of the low-level model. + */ + WiringFactory::WiringFactory (lib::AllocationCluster& a) + : alloc_(a), + pImpl_(new config::WiringFactoryImpl (alloc_)) + { } + + + /** create and configure a concrete wiring descriptor to tie * a ProcNode to its predecessor nodes. This includes selecting * the actual StateProxy type, configuring it out of some operation @@ -126,11 +143,11 @@ namespace engine { * the new processing node to be wired up. */ WiringDescriptor& - WiringFactory::operator() (WiringInstaller& setup, bool cache) + WiringFactory::operator() (WiringSituation& setup, bool cache) { UNIMPLEMENTED ("build the actual wiring descriptor based on given operation options"); - ///////////////////////////////////////////////////////////////////////////////TODO: how to get the WiringInstaller into the factory???? + ///////////////////////////////////////////////////////////////////////////////TODO: how to get the WiringSituation into the factory???? // Bits config (FlagInfo::CODE); @@ -142,4 +159,3 @@ namespace engine { } // namespace engine - /** preconfigured table of all possible factories */ diff --git a/src/proc/engine/nodewiring.hpp b/src/proc/engine/nodewiring.hpp index 3f7474e3c..160625205 100644 --- a/src/proc/engine/nodewiring.hpp +++ b/src/proc/engine/nodewiring.hpp @@ -26,6 +26,7 @@ #include "proc/engine/procnode.hpp" +#include "lib/allocationcluster.hpp" #include #include @@ -51,7 +52,7 @@ namespace engine { * and then used to initialise the wiring descriptor, which * in turn allows us to setup the ProcNode. */ - class WiringInstaller : boost::noncopyable + class WiringSituation : boost::noncopyable { public: RefArray& makeOutDescriptor() ; @@ -77,7 +78,7 @@ namespace engine { : public WiringDescriptor { - NodeWiring(WiringInstaller& setup) + NodeWiring(WiringSituation& setup) : WiringDescriptor(setup.makeOutDescriptor(), setup.makeInDescriptor(), setup.resolveProcessingFunction(), @@ -104,11 +105,14 @@ namespace engine { class WiringFactory { + lib::AllocationCluster& alloc_; boost::scoped_ptr pImpl_; public: + WiringFactory (lib::AllocationCluster& a); + WiringDescriptor& - operator() (WiringInstaller& setup, bool cache); //////////////////TODO: of course this will accept *all* the relevant flags (not only "cache") + operator() (WiringSituation& setup, bool cache); //////////////////TODO: of course this will accept *all* the relevant flags (not only "cache") };