Lumiera  0.pre.03
»edit your freedom«
tree-mutator-noop-binding.hpp
Go to the documentation of this file.
1 /*
2  TREE-MUTATOR-NOOP-BINDING.hpp - diff::TreeMutator implementation building block
3 
4  Copyright (C)
5  2018, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
40 #ifndef LIB_DIFF_TREE_MUTATOR_NOOP_BINDING_H
41 #define LIB_DIFF_TREE_MUTATOR_NOOP_BINDING_H
42 
43 
44 #include "lib/error.hpp"
45 #include "lib/diff/gen-node.hpp"
47 
48 #include <type_traits>
49 
50 namespace lib {
51 namespace diff{
52 
53  namespace { // Mutator-Builder decorator components...
54 
55 
61  : public TreeMutator
62  {
63 
64  public:
65  BlackHoleMutation () = default;
66 
67 
68  /* ==== TreeMutator API ==== */
69 
70  using Elm = GenNode const&;
71  using Buff = TreeMutator::Handle;
72 
73  bool hasSrc() override { return true; }
74 
75  bool injectNew (Elm) override { return true; }
76  bool matchSrc (Elm) override { return true; }
77  bool acceptSrc (Elm) override { return true; }
78  bool accept_until (Elm) override { return true; }
79  bool findSrc (Elm) override { return true; }
80  bool assignElm (Elm) override { return true; }
81 
82  bool
83  mutateChild (Elm, Buff buff) override
84  {
85  buff.emplace (BlackHoleMutation());
86  return true;
87  }
88  };
89 
90 
91 
100  template<class PAR>
101  inline auto
102  Builder<PAR>::ignoreAllChanges()
103  {
104  static_assert (std::is_same<PAR, TreeMutator>()
105  ,"ignoreAllChanges() must be used as bottom layer.");
106 
107  return Builder<BlackHoleMutation> (BlackHoleMutation{});
108  }
109 
110 
111 
112  }//(END)Mutator-Builder decorator components...
113 
114 }} // namespace lib::diff
115 #endif /*LIB_DIFF_TREE_MUTATOR_NOOP_BINDING_H*/
Implementation namespace for support and library code.
bool mutateChild(Elm, Buff buff) override
< ignore inferiors, yet reproduce yourself
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
Definition: record.hpp:104
Generic building block for tree shaped (meta)data structures.
Lumiera error handling (C++ interface).
Customisable intermediary to abstract generic tree mutation operations.
generic data element node within a tree
Definition: gen-node.hpp:222
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...