generating (wiring) configs now considered final

This commit is contained in:
Fischlurch 2008-08-04 05:42:55 +02:00
parent cf7bd178de
commit 29e33e4eb4
13 changed files with 308 additions and 121 deletions

View file

@ -47,7 +47,7 @@ namespace engine {
using std::vector;
class Trafo;
typedef Trafo* PTrafo; ///< @todo handle ProcNode by pointer or by shared-ptr??
typedef Trafo* PTrafo; ///< @note ProcNode is handled by pointer and bulk allocated/dealocated
/**
@ -55,10 +55,6 @@ namespace engine {
*/
class NodeFactory
{
/** custom deleter func allowing a smart-ptr
* to take ownership of processing nodes
*/
static void deleterFunc (ProcNode* pno) { delete pno; }
public:

View file

@ -23,8 +23,8 @@
/** @file nodeinvocation.hpp
** Organize the state related to the invocation of s single ProcNode::pull() call
** This header defines part of the "glue" which holds together the render node network
** and enables to pull a result frames from the nodes. Doing so requires some invocation
** local state tobe maintained, especially a table of buffers used to carry out the
** and enables to pull result frames from the nodes. Doing so requires some invocation
** local state to be maintained, especially a table of buffers used to carry out the
** calculations. Further, getting the input buffers filled requires to issue recursive
** \c pull() calls, which on the whole creates a stack-like assembly of local invocation
** state.
@ -37,7 +37,7 @@
**
** \par composition of the Invocation State
** For each individual ProcNode#pull() call, the WiringAdapter#callDown() builds an StateAdapter
** instance directly on the stack, holding the actual buffer pointers and state references. Using this
** instance directly on the stack, managing the actual buffer pointers and state references. Using this
** StateAdapter, the predecessor nodes are pulled. The way these operations are carried out is encoded
** in the actual StateAdapter type known to the NodeWiring (WiringAdapter) instance. All of these actual
** StateAdapter types are built as implementing the engine::State interface.
@ -196,7 +196,7 @@ namespace engine {
{
public:
ActualInvocationProcess (State& callingProcess, WiringDescriptor const& w, const uint outCh)
: Invocation(callingProcess, w, outCh)
: BufferProvider(callingProcess, w, outCh)
{ }
/** contains the details of Cache query and recursive calls

View file

@ -248,10 +248,10 @@ namespace engine {
template<char CACHE_Fl=0, char INPLACE_Fl=0>
struct SelectBuffProvider;
template<> struct SelectBuffProvider<CACHING> : AllocBufferFromCache { };
template<> struct SelectBuffProvider<NOT_SET,INPLACE> : AllocBufferFromParent{ };
template<> struct SelectBuffProvider<CACHING,INPLACE> : AllocBufferFromCache { };
template<> struct SelectBuffProvider<> : AllocBufferFromParent{ };
template<> struct SelectBuffProvider<CACHING> { typedef AllocBufferFromCache Type; };
template<> struct SelectBuffProvider<NOT_SET,INPLACE> { typedef AllocBufferFromParent Type; };
template<> struct SelectBuffProvider<CACHING,INPLACE> { typedef AllocBufferFromCache Type; };
template<> struct SelectBuffProvider<> { typedef AllocBufferFromParent Type; };
template<class Config>

View file

@ -30,15 +30,8 @@
namespace engine {
namespace { // internal: setting up a factory for each required configuration
using config::CACHING;
using config::PROCESS;
using config::INPLACE;
using config::ConfigSelector;
using config::Strategy;
namespace config {
using lumiera::typelist::Flags;
using lumiera::typelist::CombineFlags;
@ -49,16 +42,24 @@ namespace engine {
typedef Flags<CACHING,PROCESS,INPLACE>::Tuple AllFlags;
/** build the list of all possible flag combinations */
typedef CombineFlags<AllFlags> AllFlagCombinations;
/** build a configuration type for each of those flag combinations */
typedef Apply<AllFlagCombinations::List, DefineConfigByFlags> AllConfigs;
/** filter those configurations which actually define a wiring strategy */
typedef Filter<AllConfigs::List, Instantiation<Strategy>::Test> PossibleConfigs;
} // namespace config
namespace { // internal: setting up a factory for each required configuration
using config::ConfigSelector;
class Alloc {}; ///////////////TODO
@ -67,7 +68,7 @@ namespace engine {
class WiringDescriptorFactory
{
Alloc& alloc_;
public:
WiringDescriptorFactory(Alloc& a)
: alloc_(a) {}
@ -75,20 +76,32 @@ namespace engine {
WiringDescriptor&
operator() ()
{
/////////////////////////////////////////////TODO
//return offset_ + Maybe<CONF>::CODE;
/////////////////////////////////////////////TODO
typedef config::Strategy<CONF> Strategy;
typedef typename config::SelectBuffProvider<>::Type BuffProvider; ////////////////////////TODO: how to extract the required flags from CONF??
typedef ActualInvocationProcess<Strategy, BuffProvider> InvocationStateType;
typedef NodeWiring<InvocationStateType> Product;
Product * dummy (0);
return *dummy;
}
};
typedef ConfigSelector<WiringDescriptorFactory, WiringDescriptor&, Alloc&> WiringSelector;
typedef ConfigSelector< WiringDescriptorFactory ///< Factory template
, WiringDescriptor& ///< type of the product
, Alloc& ///< allocator fed to all factories
> WiringSelector;
struct WiringFactoryImpl
{
// WiringSelector selector;
WiringSelector selector;
WiringFactoryImpl (Alloc& alloc)
// : selector(PossibleConfigs::List(), alloc)
: selector(config::PossibleConfigs::List(), alloc)
{ }
};
@ -119,6 +132,6 @@ namespace engine {
// return pImpl_->selector(config);
}
// BlockAlloc<NodeWiring< StateAdapter< Config<cache, process, inplace> > > >::fabricate();
} // namespace engine

View file

@ -44,8 +44,9 @@ namespace engine {
* Actual implementation of the link between nodes,
* also acting as "track switch" for the execution path
* choosen while operating the node network for rendering.
* @param STATE StateAdapter object controlling the
* @param STATE Invocation state object controlling the
* behaviour of callDown() while rendering.
* @see StateAdapter
* @see NodeFactory
*/
template<class STATE>

View file

@ -99,8 +99,8 @@ namespace engine {
* heap allocated.
*/
template< template<class CONF> class Factory
, typename PAR ///< ctor parameter of the Factories
, typename RET ///< common base class of the Factory's products
, typename RET ///< common base class of the Factory's products
, typename PAR ///< ctor parameter of the Factories
>
class ConfigSelector
{

View file

@ -133,13 +133,16 @@ namespace engine {
static NodeFactory create; ///////TODO: really? probably we'll rather have a NodeFactory object in the builder...
/** Engine Core operation: render and pull output from this node.
* On return, currentProcess will hold onto output buffer(s)
* containing the calculated result frames.
* On return, currentProcess will hold onto output buffer(s)
* containing the calculated result frames. In case this node
* calculates a multi channel output, only one channel can be
* retrieved by such a \c pull() call, but you can expect data
* of the other channels to be processed and fed to cache.
* @param currentProcess the current processing state for
* managing buffers and accessing current parameter values
* @param requiredOutputNr the output channel requested (in case
* this node delivers more than one output channel)
* @return ID of the result buffer (accessible via currentProcess)
* @return handle to the buffer containing the calculated result.
*/
BuffHandle
pull (State& currentProcess, uint requiredOutputNr=0) const

View file

@ -55,7 +55,7 @@ namespace mobject {
* common selection of types to be handled by any such builder tool.
* The actual BuilderTool impl should inherit from this template by
* feeding back its type (CRTP), this causes a dispatcher table entry
* be generated for this concrete BuilderTool implementation.
* to be generated for this concrete BuilderTool implementation.
*/
template<class TOOL>
struct ApplicableBuilderTargetTypes

View file

@ -54,7 +54,7 @@ namespace mobject {
public:
/** create node(s) corresponding to the given Processor-Asset
* and wire them as a successor to this OperationPoint; then
* move this point to point at the resulting new exit node(s)
* move this point to refer to the resulting new exit node(s)
*/
void attach (asset::PProc const&);

View file

@ -50,6 +50,109 @@ out: Standard Cmdlineformat:one two
END
TEST "ConfigFlags_test" ConfigFlags_test <<END
out: Conf0 :-
out: Conf1 :-<1>-
out: Conf2 :-<2>-
out: Conf3 :-<3>-
out: Conf4 :-<2>-<4>-
out: AllFlags :-<1>-<2>-<3>-<4>-
out: ______
out: ______ check_flags()
out: Flags1 :-<2>-<4>-
out: Flags2 :-<2>-<4>-
out: SimpleConfig_defined_by_Typelist :-<1>-
out: AnotherConfig_defined_by_Typelist :-<1>-<2>-<3>-<4>-
out: ______
out: ______ check_instantiation()
out: defined Conf0? ---> 0
out: defined Conf1? ---> 1
out: defined Conf2? ---> 1
out: defined Conf3? ---> 1
out: defined Conf4? ---> 1
out: defined Trash? ---> 0
out: ______
out: ______ check_filter()
out: SomeFlagsets :
out: +---<1>-<3>-+
out: +---<2>-<4>-+-
out: Configs_defined_by_Flagsets :
out: +-Conf-[-<1>-<3>-]
out: +-Conf-[-<2>-<4>-]-
out: Filter_possible_Configs :
out: +-Conf-[-<2>-<4>-]-
out: AllFlagCombinations :
out: +---<1>-<2>-<3>-<4>-<·>-+
out: +---<1>-<2>-<3>-<·>-+
out: +---<1>-<2>-<4>-<·>-+
out: +---<1>-<2>-<·>-+
out: +---<1>-<3>-<4>-<·>-+
out: +---<1>-<3>-<·>-+
out: +---<1>-<4>-<·>-+
out: +---<1>-<·>-+
out: +---<2>-<3>-<4>-<·>-+
out: +---<2>-<3>-<·>-+
out: +---<2>-<4>-<·>-+
out: +---<2>-<·>-+
out: +---<3>-<4>-<·>-+
out: +---<3>-<·>-+
out: +---<4>-<·>-+
out: +---<·>-+-
out: ListAllConfigs :
out: +-Conf-[-<1>-<2>-<3>-<4>-]
out: +-Conf-[-<1>-<2>-<3>-]
out: +-Conf-[-<1>-<2>-<4>-]
out: +-Conf-[-<1>-<2>-]
out: +-Conf-[-<1>-<3>-<4>-]
out: +-Conf-[-<1>-<3>-]
out: +-Conf-[-<1>-<4>-]
out: +-Conf-[-<1>-]
out: +-Conf-[-<2>-<3>-<4>-]
out: +-Conf-[-<2>-<3>-]
out: +-Conf-[-<2>-<4>-]
out: +-Conf-[-<2>-]
out: +-Conf-[-<3>-<4>-]
out: +-Conf-[-<3>-]
out: +-Conf-[-<4>-]
out: +-Conf-[-]-
out: Filter_all_possible_Configs :
out: +-Conf-[-<1>-]
out: +-Conf-[-<2>-<3>-]
out: +-Conf-[-<2>-<4>-]
out: +-Conf-[-<2>-]
out: +-Conf-[-<3>-]-
out: ______
out: ______ check_FlagInfo()
out: Flags1 :-<1>-<3>-
out: max bit : 3
out: binary code: 10
out: SomeConfigs :
out: +-Conf-[-<1>-<3>-]
out: +-Conf-[-<2>-<4>-]-
out: max bit in [SomeConfigs] : 4
out: TestVisitor application:
out: visit(code=10) -->
out: +-Conf-[-<1>-<3>-]-
out: visit(code=20) -->
out: +-Conf-[-<2>-<4>-]-
out: ______
out: ______ check_ConfigSelector()
out: Possible_Configs :
out: +-Conf-[-<1>-]
out: +-Conf-[-<2>-<3>-]
out: +-Conf-[-<2>-<4>-]
out: +-Conf-[-<2>-]
out: +-Conf-[-<3>-]-
out: Flag-code = 2 ConfigSelector() ---> 1010
out: Flag-code = 12 ConfigSelector() ---> 1023
out: Flag-code = 20 ConfigSelector() ---> 1024
out: Flag-code = 4 ConfigSelector() ---> 1020
out: Flag-code = 8 ConfigSelector() ---> 1030
out: LUMIERA_ERROR_INVALID:invalid input or parameters (ConfigSelector: No preconfigured factory for config-bits=23).
return: 0
END
TEST "CustomSharedPtr_test" CustomSharedPtr_test <<END
return: 0
END
@ -220,7 +323,7 @@ return: 0
END
TEST "TypeListUtil_test" TypeListUtil_test <<END
TEST "TypeListGenerator_test" TypeListGenerator_test <<END
out: ctor DoIt<Block<13> >
out: ctor DoIt<Block< 8> >
out: ctor DoIt<Block< 5> >
@ -241,6 +344,106 @@ return: 0
END
TEST "TypeListManipl_test" TypeListManipl_test <<END
out: List1 :-<1>-<2>-<3>-
out: List2 :-<5>-<6>-<7>-
out: Added2 :-<3>-<4>-<5>-
out: Append1 :-
out: Append2 :-<11>-<22>-
out: Append3 :-<111>-
out: Append4 :-<222>-
out: Append5 :-<1>-<2>-<3>-
out: Append6 :-<5>-<6>-<7>-
out: Append7 :-<111>-<5>-<6>-<7>-
out: Append8 :-<1>-<2>-<3>-<222>-
out: Append9 :-<1>-<2>-<3>-<5>-<6>-<7>-
out: FilterEven :-<2>-<6>-
out: Prefix1 :
out: +---<11>-<22>-+-
out: Prefix2 :
out: +---<101>-<1>-+
out: +---<101>-<2>-+
out: +---<101>-<3>-+-
out: Prefix3 :
out: +---<1>-+
out: +---<2>-+
out: +---<3>-+-
out: Prefix4 :
out: +---<111>-<1>-<2>-<3>-+
out: +---<111>-<0>-+
out: +---<111>-<5>-<6>-<7>-+-
out: Prefix5 :
out: +---<1>-<2>-<3>-<5>-+
out: +---<1>-<2>-<3>-<6>-+
out: +---<1>-<2>-<3>-<7>-+-
out: Prefix6 :
out: +---<1>-<2>-<3>-<1>-<2>-<3>-+
out: +---<1>-<2>-<3>-<0>-+
out: +---<1>-<2>-<3>-<5>-<6>-<7>-+-
out: Dist1 :
out: +---<11>-<1>-+
out: +---<11>-<2>-+
out: +---<11>-<3>-+-
out: Dist2 :
out: +---<11>-<0>-+
out: +---<22>-<0>-+
out: +---<33>-<0>-+-
out: Dist3 :
out: +---<11>-<1>-+
out: +---<11>-<2>-+
out: +---<11>-<3>-+
out: +---<22>-<1>-+
out: +---<22>-<2>-+
out: +---<22>-<3>-+
out: +---<33>-<1>-+
out: +---<33>-<2>-+
out: +---<33>-<3>-+-
out: Dist4 :
out: +---<11>-<1>-<2>-<3>-+
out: +---<11>-<5>-<6>-<7>-+
out: +---<22>-<1>-<2>-<3>-+
out: +---<22>-<5>-<6>-<7>-+
out: +---<33>-<1>-<2>-<3>-+
out: +---<33>-<5>-<6>-<7>-+-
out: Down :-<11>-<10>-<9>-<8>-<7>-<6>-<5>-<4>-<3>-<2>-<1>-<0>-
out: Combi :
out: +---<1>-<2>-<3>-<·>-+
out: +---<1>-<2>-<2>-<·>-+
out: +---<1>-<2>-<1>-<·>-+
out: +---<1>-<2>-<0>-<·>-+
out: +---<1>-<1>-<3>-<·>-+
out: +---<1>-<1>-<2>-<·>-+
out: +---<1>-<1>-<1>-<·>-+
out: +---<1>-<1>-<0>-<·>-+
out: +---<1>-<0>-<3>-<·>-+
out: +---<1>-<0>-<2>-<·>-+
out: +---<1>-<0>-<1>-<·>-+
out: +---<1>-<0>-<0>-<·>-+
out: +---<0>-<2>-<3>-<·>-+
out: +---<0>-<2>-<2>-<·>-+
out: +---<0>-<2>-<1>-<·>-+
out: +---<0>-<2>-<0>-<·>-+
out: +---<0>-<1>-<3>-<·>-+
out: +---<0>-<1>-<2>-<·>-+
out: +---<0>-<1>-<1>-<·>-+
out: +---<0>-<1>-<0>-<·>-+
out: +---<0>-<0>-<3>-<·>-+
out: +---<0>-<0>-<2>-<·>-+
out: +---<0>-<0>-<1>-<·>-+
out: +---<0>-<0>-<0>-<·>-+-
out: OnOff :
out: +---<1>-<2>-<3>-<·>-+
out: +---<1>-<2>-<·>-+
out: +---<1>-<3>-<·>-+
out: +---<1>-<·>-+
out: +---<2>-<3>-<·>-+
out: +---<2>-<·>-+
out: +---<3>-<·>-+
out: +---<·>-+-
return: 0
END
TEST "VisitingTool_test" VisitingTool_test <<END
out: === Babbler meets Boss and BigBoss ===
out: Hello Boss, nice to meet you...

View file

@ -52,7 +52,6 @@
using ::test::Test;
using std::string;
using std::cout;
using boost::format;
namespace lumiera {
@ -113,6 +112,7 @@ namespace lumiera {
} // (End) internal defs
#define DELIMITER(TITLE) cout << "______\n______ " << STRINGIFY(TITLE) << "\n";
@ -155,7 +155,7 @@ namespace lumiera {
/** @test conversion between list-of-flags and a config-type in both directions */
void check_flags ()
{
cout << "\n==== check_flags()\n";
DELIMITER (check_flags());
typedef Config<TWO,FOU> Flags1;
typedef Flags<TWO,FOU> Flags2;
@ -186,7 +186,8 @@ namespace lumiera {
<< "? ---> " \
<< Instantiation<Maybe>::Test<NAME>::value << "\n";
cout << "\n==== check_instantiation()\n";
DELIMITER (check_instantiation());
CAN_INSTANTIATE (Conf0);
CAN_INSTANTIATE (Conf1);
CAN_INSTANTIATE (Conf2);
@ -203,7 +204,7 @@ namespace lumiera {
*/
void check_filter ()
{
cout << "\n==== check_filter()\n";
DELIMITER (check_filter());
DISPLAY (SomeFlagsets);
@ -238,7 +239,7 @@ namespace lumiera {
void
visit (ulong code)
{
result += str (format ("visit(code=%u) --> %s\n")
result += str (format ("visit(code=%u) -->%s\n")
% code % Printer<CONF>::print() );
}
};
@ -249,7 +250,7 @@ namespace lumiera {
*/
void check_FlagInfo()
{
cout << "\n==== check_FlagInfo()\n";
DELIMITER (check_FlagInfo());
DISPLAY (Flags1);
cout << "max bit : " << FlagInfo<Flags1>::BITS <<"\n";
@ -281,13 +282,16 @@ namespace lumiera {
*/
void check_ConfigSelector()
{
cout << "\n==== check_ConfigSelector()\n";
DELIMITER (check_ConfigSelector());
typedef Apply<AllFlagCombinations::List, DefineConfigByFlags> ListAllConfigs;
typedef Filter<ListAllConfigs::List,Instantiation<Maybe>::Test> Possible_Configs;
DISPLAY (Possible_Configs);
typedef engine::config::ConfigSelector<TestFactory, long, uint> TestFactorySelector;
typedef engine::config::ConfigSelector< TestFactory // Factory template
, uint // product type
, long // common ctor argument
> TestFactorySelector;
const long offset = 1000; // parameter fed to all TestFactory ctors
TestFactorySelector testConfigSelector (Possible_Configs::List(), offset);

View file

@ -37,6 +37,7 @@
#include "common/meta/generator.hpp"
//#include "common/meta/typelistutil.hpp"
//#include "common/meta/util.hpp"
//#include "common/util.hpp"
@ -49,11 +50,33 @@ using boost::format;
namespace lumiera {
namespace typelist {
/** constant-wrapper type for debugging purposes,
* usable for generating lists of distinguishable types
*/
template<int I>
struct Num
{
enum{ VAL=I };
};
/* some forwards used by configflagstest.cpp */
template<char bit> struct Flag;
template< char f1
, char f2
, char f3
, char f4
, char f5
>
struct Config;
namespace test {
namespace { // internal definitions
using boost::format;
format fmt ("-<%u>%s");
@ -75,8 +98,15 @@ namespace lumiera {
static string print () { return str( fmt % "·" % BASE::print()); }
};
template<class BASE, int I>
struct Printer<Num<I>, BASE> ///< display the presence of a Num instance in the typelist
: BASE
{
static string print () { return str( fmt % uint(Num<I>::VAL) % BASE::print()); }
};
template<class BASE, char Fl>
struct Printer<Flag<Fl>, BASE>
struct Printer<Flag<Fl>, BASE> ///< display the presence of a Flag in the typelist
: BASE
{
static string print () { return str( fmt % uint(Fl) % BASE::print()); }
@ -124,7 +154,7 @@ namespace lumiera {
typedef InstantiateChained<LIST::List, Printer, NullP> Contents_##LIST;
#define DISPLAY(NAME) \
DIAGNOSE(NAME); cout << STRINGIFY(NAME) << "\t" << Contents_##NAME::print() << "\n";
DIAGNOSE(NAME); cout << STRINGIFY(NAME) << "\t:" << Contents_##NAME::print() << "\n";

View file

@ -41,6 +41,7 @@
#include "common/test/run.hpp"
#include "common/meta/generator.hpp"
#include "common/meta/typelistutil.hpp"
#include "meta/typelistdiagnostics.hpp"
#include "common/util.hpp"
#include <boost/format.hpp>
@ -56,65 +57,7 @@ namespace lumiera {
namespace test {
namespace { // internal definitions
boost::format fmt ("<%i>");
/** constant-wrapper type for debugging purposes,
* usable for generating lists of distinguishable types
*/
template<int I>
struct Num
{
enum{ VAL=I };
static string str () { return boost::str (fmt % I); }
};
/** debugging template,
* printing the "number" used for intantiation
*/
template<class NUM=NullType, class BASE=NullType>
struct Printer;
template<class X>
struct Printer<NullType, X>
{
static string print () { return "-"; }
};
template<class BASE, int I>
struct Printer<Num<I>, BASE>
: BASE
{
static string print () { return string("-") + Num<I>::str() + BASE::print(); }
};
typedef Printer<NullType> NullP;
/** call the debug-print for a typelist
* utilizing the Printer template */
template<class L>
string
printSublist ()
{
typedef InstantiateChained<L, Printer, NullP> SubList;
return SubList::print();
}
/** Spezialisation for debug-printing of a nested sublist */
template<class TY, class TYPES, class BASE>
struct Printer<Node<TY,TYPES>, BASE>
: BASE
{
static string print ()
{
typedef Node<TY,TYPES> List;
return string("\n\t+--") + printSublist<List>()+"+"
+ BASE::print();
}
};
namespace { // test data
@ -131,16 +74,10 @@ namespace lumiera {
template<class X> struct CountDown { typedef NullType List; };
template<> struct CountDown<Num<0> > { typedef Node<Num<0>, NullType> List; };
template<int I> struct CountDown<Num<I> > { typedef Node<Num<I>, typename CountDown<Num<I-1> >::List> List; };
#define DIAGNOSE(LIST) \
typedef InstantiateChained<LIST::List, Printer, NullP> Contents_##LIST;
#define DISPLAY(NAME) \
DIAGNOSE(NAME); cout << STRINGIFY(NAME) << "\t" << Contents_##NAME::print() << "\n";
} // (End) internal defs
} // (End) test data
@ -174,8 +111,8 @@ namespace lumiera {
void check_diagnostics ()
{
// Explanation: the DISPLAY macro expands as follows....
typedef InstantiateChained<List1::List, Printer, Printer<NullType> > Contents_List1;
cout << "List1" << "\t" << Contents_List1::print() << "\n";
typedef InstantiateChained<List1::List, Printer, NullP > Contents_List1;
cout << "List1" << "\t:" << Contents_List1::print() << "\n";
// That is: we instantiate the "Printer" template for each of the types in List1,
// forming an inheritance chain. I.e. the defined Type "Contents_List1" inherits