set up the full builder definition chain
This commit is contained in:
parent
5579e9c86f
commit
1b24453f5b
2 changed files with 182 additions and 1 deletions
|
|
@ -555,6 +555,150 @@ namespace diff{
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Nested DSL to define the specifics of a collection binding.
|
||||
*/
|
||||
template<class COLL, class MAT, class CTR, class SEL, class ASS, class MUT>
|
||||
struct CollectionBindingBuilder
|
||||
: CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT>
|
||||
{
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL, FUN ,CTR,SEL,ASS,MUT>
|
||||
matchElement(FUN matcher)
|
||||
{
|
||||
return { this->collection
|
||||
, matcher
|
||||
, this->construct
|
||||
, this->isApplicable
|
||||
, this->assign
|
||||
, this->openSub
|
||||
};
|
||||
}
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL,MAT, FUN ,SEL,ASS,MUT>
|
||||
constructFrom(FUN constructor)
|
||||
{
|
||||
return { this->collection
|
||||
, this->matches
|
||||
, constructor
|
||||
, this->isApplicable
|
||||
, this->assign
|
||||
, this->openSub
|
||||
};
|
||||
}
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL,MAT,CTR, FUN ,ASS,MUT>
|
||||
isApplicableIf(FUN selector)
|
||||
{
|
||||
return { this->collection
|
||||
, this->matches
|
||||
, this->construct
|
||||
, selector
|
||||
, this->assign
|
||||
, this->openSub
|
||||
};
|
||||
}
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL,MAT,CTR,SEL, FUN ,MUT>
|
||||
assignElement(FUN setter)
|
||||
{
|
||||
return { this->collection
|
||||
, this->matches
|
||||
, this->construct
|
||||
, this->isApplicable
|
||||
, setter
|
||||
, this->openSub
|
||||
};
|
||||
}
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL,MAT,CTR,SEL,ASS, FUN >
|
||||
buildChildMutator(FUN childMutationBuilder)
|
||||
{
|
||||
return { this->collection
|
||||
, this->matches
|
||||
, this->construct
|
||||
, this->isApplicable
|
||||
, this->assign
|
||||
, childMutationBuilder
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
template<class COLL>
|
||||
struct _DefaultBinding
|
||||
{
|
||||
using Coll = typename Strip<COLL>::TypeReferred;
|
||||
using Elm = typename Coll::value_type;
|
||||
|
||||
static bool
|
||||
disable_selector (GenNode const& spec)
|
||||
{
|
||||
UNIMPLEMENTED ("dont discriminate by default");
|
||||
}
|
||||
|
||||
static bool
|
||||
default_contantMatch (Elm const& elm)
|
||||
{
|
||||
UNIMPLEMENTED ("fallback matcher");
|
||||
}
|
||||
|
||||
static Elm
|
||||
default_construct_from_payload (GenNode const& spec)
|
||||
{
|
||||
UNIMPLEMENTED ("default construct from spec payload");
|
||||
}
|
||||
|
||||
static bool
|
||||
disable_assignment (GenNode const& spec)
|
||||
{
|
||||
UNIMPLEMENTED ("disabled assignment");
|
||||
}
|
||||
|
||||
static bool
|
||||
disable_childMutation (GenNode const& spec, TreeMutator::MutatorBuffer targetBuff)
|
||||
{
|
||||
UNIMPLEMENTED ("inactive mutator builder");
|
||||
}
|
||||
|
||||
|
||||
using FallbackBindingConfiguration
|
||||
= CollectionBindingBuilder<Coll
|
||||
,decltype(disable_selector)
|
||||
,decltype(default_contantMatch)
|
||||
,decltype(default_construct_from_payload)
|
||||
,decltype(disable_assignment)
|
||||
,decltype(disable_childMutation)
|
||||
>;
|
||||
|
||||
static FallbackBindingConfiguration
|
||||
attachTo (Coll& coll)
|
||||
{
|
||||
return { coll
|
||||
, disable_selector
|
||||
, default_contantMatch
|
||||
, default_construct_from_payload
|
||||
, disable_assignment
|
||||
, disable_childMutation
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class COLL>
|
||||
auto
|
||||
collection (COLL& coll) -> decltype(_DefaultBinding<COLL>::attachTo(coll))
|
||||
{
|
||||
return _DefaultBinding<COLL>::attachTo(coll);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class PAR>
|
||||
struct TestWireTap;
|
||||
|
||||
|
|
@ -570,6 +714,9 @@ namespace diff{
|
|||
template<class CLO>
|
||||
using Change = ChangeOperation<PAR,CLO>;
|
||||
|
||||
template<class BIN>
|
||||
using Collection = ChildCollectionMutator<PAR,BIN>;
|
||||
|
||||
using WireTap = TestWireTap<PAR>;
|
||||
|
||||
|
||||
|
|
@ -582,6 +729,13 @@ namespace diff{
|
|||
return Change<CLO> (attributeID, closure, *this);
|
||||
}
|
||||
|
||||
template<typename BIN>
|
||||
Builder<Collection<BIN>>
|
||||
attach (BIN&& collectionBindingSetup)
|
||||
{
|
||||
return Collection<BIN> (std::forward<BIN>(collectionBindingSetup));
|
||||
}
|
||||
|
||||
Builder<WireTap>
|
||||
attachDummy (TestMutationTarget& dummy);
|
||||
|
||||
|
|
|
|||
|
|
@ -2339,7 +2339,34 @@
|
|||
</node>
|
||||
<node CREATED="1458178288690" ID="ID_562189277" MODIFIED="1458178295494" TEXT="Implementierung">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1458178298328" ID="ID_1964300614" MODIFIED="1458178300324" TEXT="Builder"/>
|
||||
<node CREATED="1458178298328" ID="ID_1964300614" MODIFIED="1458178300324" TEXT="Builder">
|
||||
<node CREATED="1458325962991" ID="ID_1955400674" MODIFIED="1458325972586" TEXT="Typ definitionen schwierig anzuschreiben"/>
|
||||
<node CREATED="1458325973486" ID="ID_1711903796" MODIFIED="1458325992405" TEXT="Code ziemlich redundant und undurchsichtig">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
<node CREATED="1458326045724" ID="ID_338749301" MODIFIED="1458326138100" TEXT="Typ-Check erst sehr spät">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...will sagen,
|
||||
</p>
|
||||
<p>
|
||||
da sind mehrere Layer an praktisch ungebundenem Template-Code dazwischen,
|
||||
</p>
|
||||
<p>
|
||||
so daß zu befürchten steht, daß ein unpassendes Lambda erst weit entfernt
|
||||
</p>
|
||||
<p>
|
||||
eine womöglich irreführende Meldung generiert
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1458178300984" ID="ID_1152672899" MODIFIED="1458178309971" TEXT="Binding-Layer"/>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue