Lumiera  0.pre.03
»edit your freedom«
DiffTreeMutationListener_test Class Reference

Description

Test:
When creating a TreeMutator binding, a listener (lambda) can be attached, to be invoked on structural changes...
  • inserting, removing and reordering of children counts as "structural" change
  • whereas assignment of a new value will only trigger onLocalChange()
  • mutation of nested scopes does not trigger any of these listeners, since (within the existing framework) there is no simple way to intercept also the child mutation stream to check for relevance.
    Note
    This test binds the test class itself for diff mutation, applying changes onto a vector with test data. The binding itself is somewhat unusual, insofar it allows to re-assign elements within the vector, which can be identified and picked by equality match. In actual code, you would not do that, since typically you'd distinguish between attributes, which are marked by an identifier and can be reassigned, and children, which are treated as sequence and maybe re-ordered. However, the diff system as such does not enforce such conventions; if you want to find a sub-element, you need to provide a matcher to identify it, given a suitable "spec" in the relevant diff verbs.
    Remarks
    Now the special rigging for this test is that we match case-insensitively, which allows to assign a different value, while this value still counts as "equal", as far as matching is concerned. We do all this trickery in order to apply a diff, which changes values while not changing the structure.
    See also
    DiffTreeApplicationSimple_test introductory example demonstration
    DiffTreeApplication_test extended demonstration of possible diff operations
    DiffComplexApplication_test handling arbitrary data structures
    GenericRecord_test
    GenNode_test

Definition at line 114 of file diff-tree-mutation-listener-test.cpp.

Private Member Functions

void buildMutator (TreeMutator::Handle buff) override
 rig the test class itself to receive a diff mutation. More...
 
virtual void run (Arg)
 
- Private Member Functions inherited from TreeDiffLanguage
 DiffStep_CTOR (ins)
 
 DiffStep_CTOR (del)
 
 DiffStep_CTOR (pick)
 
 DiffStep_CTOR (find)
 
 DiffStep_CTOR (skip)
 
 DiffStep_CTOR (after)
 
 DiffStep_CTOR (set)
 
 DiffStep_CTOR (mut)
 
 DiffStep_CTOR (emu)
 

Private Attributes

int localChanges_ = 0
 
int structChanges_ = 0
 
std::vector< string > subject_
 

Additional Inherited Members

- Public Member Functions inherited from DiffMutable
virtual ~DiffMutable ()
 this is an interface
 
- Private Types inherited from TreeDiffLanguage
using Interpreter = TreeDiffInterpreter
 
- Private Types inherited from DiffLanguage< TreeDiffInterpreter, GenNode >
using DiffToken = std::tuple< DiffVerb, GenNode >
 
using DiffVerb = VerbToken< TreeDiffInterpreter, void(GenNode const &)>
 
using Interpreter = TreeDiffInterpreter
 
- Static Private Attributes inherited from DiffLanguage< TreeDiffInterpreter, GenNode >
static const DiffStep NIL
 fixed "invalid" marker token More...
 

Member Function Documentation

◆ buildMutator()

void buildMutator ( TreeMutator::Handle  buff)
inlineoverrideprivatevirtual

rig the test class itself to receive a diff mutation.

  • bind the #subject_ data collection to be changed by diff
  • attach a listener, to be invoked on structural changes
  • attach another listener, activated both on structural changes and on value assignment.

Implements DiffMutable.

Definition at line 130 of file diff-tree-mutation-listener-test.cpp.

References TreeMutator::build(), lib::diff::anonymous_namespace{tree-mutator-collection-binding.hpp}::collection(), and PlantingHandle< BA, DEFAULT >::emplace().

+ Here is the call graph for this function:
+ Inheritance diagram for DiffTreeMutationListener_test:
+ Collaboration diagram for DiffTreeMutationListener_test:

The documentation for this class was generated from the following file: