solution to integrate heap based storage for nested scopes
This commit is contained in:
parent
78c9b0835e
commit
d1bbf01029
3 changed files with 84 additions and 0 deletions
|
|
@ -148,6 +148,13 @@ namespace diff{
|
|||
};
|
||||
|
||||
|
||||
template<class TAR>
|
||||
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<TAR, enable_if<TreeDiffTraits<TAR>>>
|
||||
: public TreeDiffMutatorBinding
|
||||
{
|
||||
using Scopes = StackScopeManager<TreeMutatorSizeTraits<TAR>::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);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@
|
|||
namespace lib {
|
||||
namespace diff{
|
||||
|
||||
ScopeManager::~ScopeManager() { }; ///< emit VTable here...
|
||||
|
||||
|
||||
/* ======= Implementation of Tree Diff Application via TreeMutator ======= */
|
||||
|
||||
using util::unConst;
|
||||
|
|
|
|||
|
|
@ -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<size_t buffSiz>
|
||||
class StackScopeManager
|
||||
: public ScopeManager
|
||||
{
|
||||
using MutatorBuffer = InPlaceBuffer<TreeMutator, buffSiz>;
|
||||
using MutatorStack = std::stack<MutatorBuffer>;
|
||||
|
||||
/** 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 ======= */
|
||||
|
|
|
|||
Loading…
Reference in a new issue