diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index 2d372611b..b402f11bb 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -148,6 +148,13 @@ namespace diff{ }; + template + struct TreeMutatorSizeTraits + { + enum { siz = 200 }; + }; + + /** * Extended configuration for tree-diff-application to given opaque target data. * This setup uses the [metaprogramming adapter traits](\ref TreeDiffTraits) to @@ -162,7 +169,12 @@ namespace diff{ class DiffApplicationStrategy>> : public TreeDiffMutatorBinding { + using Scopes = StackScopeManager::siz>; + + TAR& subject_; + Scopes scopes_; + void buildMutator (DiffMutable& targetBinding) @@ -177,6 +189,7 @@ namespace diff{ DiffApplicationStrategy(TAR& subject) : TreeDiffMutatorBinding() , subject_(subject) + , scopes_() { auto target = mutatorBinding (subject); buildMutator (target); diff --git a/src/lib/diff/tree-diff-mutator-binding.cpp b/src/lib/diff/tree-diff-mutator-binding.cpp index 7bf13f4a8..8ef61d77c 100644 --- a/src/lib/diff/tree-diff-mutator-binding.cpp +++ b/src/lib/diff/tree-diff-mutator-binding.cpp @@ -48,6 +48,9 @@ namespace lib { namespace diff{ + ScopeManager::~ScopeManager() { }; ///< emit VTable here... + + /* ======= Implementation of Tree Diff Application via TreeMutator ======= */ using util::unConst; diff --git a/src/lib/diff/tree-diff-mutator-binding.hpp b/src/lib/diff/tree-diff-mutator-binding.hpp index 1c302dcd1..6a379d28d 100644 --- a/src/lib/diff/tree-diff-mutator-binding.hpp +++ b/src/lib/diff/tree-diff-mutator-binding.hpp @@ -94,6 +94,74 @@ namespace lib { namespace diff{ + /** + * Management interface to deal with storage for + * TreeMutators dedicated to nested scopes + */ + class ScopeManager + : boost::noncopyable + { + public: + virtual ~ScopeManager(); ///< this is an interface + + virtual TreeMutator::Handle openScope() =0; + virtual TreeMutator& closeScope() =0; + + virtual size_t depth() const =0; + }; + + + + /** + * Typical standard implementation of the ScopeManager. + * Using Heap memory for the nested scopes, we create a stack + * of opaque InPlaceBuffers for each scope, which allows the + * PlantingHandle mechanism to let the target object corresponding + * to this scope build its own TreeMutator implementation into + * this buffer space for this scope. + */ + template + class StackScopeManager + : public ScopeManager + { + using MutatorBuffer = InPlaceBuffer; + using MutatorStack = std::stack; + + /** Allocate Heap Storage for nested TreeMutator(s) */ + MutatorStack scopes_; + + + /* ==== ScopeManager interface ==== */ + + virtual TreeMutator::Handle + openScope() + { + UNIMPLEMENTED("push stack and open new scope"); +// TreeMutator::Handle placementHandle(subMutatorBuffer); + + /////TODO static_assert on buffer size!!!!!!! + } + + virtual TreeMutator& + closeScope() + { + UNIMPLEMENTED("pop stack and return to parent scope"); + } + + + virtual size_t + depth() const + { + return scopes_.size(); + } + + + public: + StackScopeManager() + : scopes_() + { } + }; + /* ======= Implementation of Tree Diff Application via TreeMutator ======= */