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) Lumiera.org
5  2018, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
49 #ifndef LIB_DIFF_TREE_MUTATOR_NOOP_BINDING_H
50 #define LIB_DIFF_TREE_MUTATOR_NOOP_BINDING_H
51 
52 
53 #include "lib/error.hpp"
54 #include "lib/diff/gen-node.hpp"
56 
57 #include <type_traits>
58 
59 namespace lib {
60 namespace diff{
61 
62  namespace { // Mutator-Builder decorator components...
63 
64 
70  : public TreeMutator
71  {
72 
73  public:
74  BlackHoleMutation () = default;
75 
76 
77  /* ==== TreeMutator API ==== */
78 
79  using Elm = GenNode const&;
80  using Buff = TreeMutator::Handle;
81 
82  bool hasSrc() override { return true; }
83 
84  bool injectNew (Elm) override { return true; }
85  bool matchSrc (Elm) override { return true; }
86  bool acceptSrc (Elm) override { return true; }
87  bool accept_until (Elm) override { return true; }
88  bool findSrc (Elm) override { return true; }
89  bool assignElm (Elm) override { return true; }
90 
91  bool
92  mutateChild (Elm, Buff buff) override
93  {
94  buff.emplace (BlackHoleMutation());
95  return true;
96  }
97  };
98 
99 
100 
109  template<class PAR>
110  inline auto
111  Builder<PAR>::ignoreAllChanges()
112  {
113  static_assert (std::is_same<PAR, TreeMutator>()
114  ,"ignoreAllChanges() must be used as bottom layer.");
115 
116  return Builder<BlackHoleMutation> (BlackHoleMutation{});
117  }
118 
119 
120 
121  }//(END)Mutator-Builder decorator components...
122 
123 }} // namespace lib::diff
124 #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:113
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:231
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...