Lumiera  0.pre.03
»edityourfreedom«
TreeMutator Class Reference

#include "lib/diff/tree-mutator.hpp"

Description

Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data.

The TreeMutator exposes two distinct interfaces

  • the operation API – similar to what a container exposes – is the entirety of abstract operations that can be done to the subsumed, tree like target structure
  • the binding API allows to link some or all of these generic activities to concrete manipulations known within target scope.

Definition at line 142 of file tree-mutator.hpp.

Public Types

using Handle = PlantingHandle< TreeMutator >
 

Public Member Functions

 TreeMutator ()=default
 
 TreeMutator (TreeMutator &&)=default
 
virtual ~TreeMutator ()
 this is an interface More...
 
virtual bool accept_until (GenNode const &spec)
 repeatedly accept, until after the designated location More...
 
virtual bool acceptSrc (GenNode const &)
 accept existing element, when matching the given spec More...
 
virtual bool assignElm (GenNode const &)
 locate the designated target element (must be already accepted into the target sequence). More...
 
virtual bool completeScope ()
 ensure the scope addressed by this TreeMutator was processed and exhausted without mismatch More...
 
virtual bool findSrc (GenNode const &)
 locate designated element and accept it at current position More...
 
virtual bool hasSrc ()
 
virtual void init ()
 initialisation immediately before start of diff application More...
 
virtual bool injectNew (GenNode const &)
 establish new element at current position More...
 
virtual bool matchSrc (GenNode const &)
 ensure the next source element matches with given spec More...
 
virtual bool mutateChild (GenNode const &, Handle)
 locate the designated target element and build a suitable sub-mutator for this element into the provided target buffer More...
 
virtual void skipSrc (GenNode const &)
 skip next src element and advance abstract source position. More...
 

Static Public Member Functions

static Builder< TreeMutatorbuild ()
 DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrappers into the current implementation context. More...
 

Additional Inherited Members

- Private Member Functions inherited from MoveOnly
 MoveOnly ()=default
 
 MoveOnly (MoveOnly &&)=default
 
 MoveOnly (MoveOnly const &)=delete
 
 ~MoveOnly ()=default
 
MoveOnlyoperator= (MoveOnly &&)=delete
 
MoveOnlyoperator= (MoveOnly const &)=delete
 

Member Typedef Documentation

◆ Handle

Definition at line 244 of file tree-mutator.hpp.

Constructor & Destructor Documentation

◆ ~TreeMutator()

~TreeMutator ( )
virtual

this is an interface

emit VTables here...

Definition at line 51 of file tree-diff.cpp.

◆ TreeMutator() [1/2]

TreeMutator ( )
default

◆ TreeMutator() [2/2]

TreeMutator ( TreeMutator &&  )
default

Member Function Documentation

◆ init()

virtual void init ( )
inlinevirtual

initialisation immediately before start of diff application

Remarks
allows for setup of state which is dependent on memory location, like e.g. iterators. Due to the invocation via Builder DSL, the implementation object may be moved after construction, but prior to invoking this hook

Definition at line 164 of file tree-mutator.hpp.

◆ hasSrc()

virtual bool hasSrc ( )
inlinevirtual

Definition at line 167 of file tree-mutator.hpp.

◆ injectNew()

virtual bool injectNew ( GenNode const &  )
inlinevirtual

establish new element at current position

Returns
true when successfully inserted something

Definition at line 176 of file tree-mutator.hpp.

◆ matchSrc()

virtual bool matchSrc ( GenNode const &  )
inlinevirtual

ensure the next source element matches with given spec

Definition at line 184 of file tree-mutator.hpp.

◆ skipSrc()

virtual void skipSrc ( GenNode const &  )
inlinevirtual

skip next src element and advance abstract source position.

The argument shall be used to determine applicability

Remarks
this operation is used both to implement the del verb and the skip verb. Since the latter discards garbage left back by find we must not touch the contents, to prevent a SEGFAULT. Thus skipSrc can not match and thus can not return anything. Consequently the del implementation has to use matchSrc explicitly, and the latter must invoke the selector prior to performing the local match.

Definition at line 201 of file tree-mutator.hpp.

◆ acceptSrc()

virtual bool acceptSrc ( GenNode const &  )
inlinevirtual

accept existing element, when matching the given spec

Definition at line 208 of file tree-mutator.hpp.

◆ accept_until()

virtual bool accept_until ( GenNode const &  spec)
inlinevirtual

repeatedly accept, until after the designated location

Definition at line 216 of file tree-mutator.hpp.

References Ref::ATTRIBS, and Ref::END.

◆ findSrc()

virtual bool findSrc ( GenNode const &  )
inlinevirtual

locate designated element and accept it at current position

Definition at line 225 of file tree-mutator.hpp.

◆ assignElm()

virtual bool assignElm ( GenNode const &  )
inlinevirtual

locate the designated target element (must be already accepted into the target sequence).

Perform an assignment with the given payload value

Exceptions
whenassignment fails (typically error::Logic)
Returns
false when unable to locate the target

Definition at line 237 of file tree-mutator.hpp.

◆ mutateChild()

virtual bool mutateChild ( GenNode const &  ,
Handle   
)
inlinevirtual

locate the designated target element and build a suitable sub-mutator for this element into the provided target buffer

Exceptions
error::Fatalwhen buffer is insufficient
Returns
false when unable to locate the target

Definition at line 252 of file tree-mutator.hpp.

◆ completeScope()

virtual bool completeScope ( )
inlinevirtual

ensure the scope addressed by this TreeMutator was processed and exhausted without mismatch

Returns
true when all "open ends" are closed and no pending work remains to be done.

Definition at line 263 of file tree-mutator.hpp.

◆ build()

Builder< TreeMutator > build ( )
inlinestatic

DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrappers into the current implementation context.

Definition at line 451 of file tree-mutator.hpp.

Referenced by Record< VAL >::Mutator::buildMutator(), NotificationHub::buildMutator(), MockElm::buildMutator(), DiffIgnoreChanges_test::fail_or_ignore(), DiffIgnoreChanges_test::fish_for_content(), TestMutationTarget::getLog(), TreeMutatorBinding_test::mutateAttribute(), TreeMutatorBinding_test::mutateCollection(), TreeMutatorBinding_test::mutateDummy(), TreeMutatorBinding_test::mutateGenNode(), TreeMutator_test::simpleAttributeBinding(), and TreeMutator_test::simpleCollectionBinding().

+ Here is the caller graph for this function:
+ Inheritance diagram for TreeMutator:
+ Collaboration diagram for TreeMutator:

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