Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
mutation-message.hpp
Go to the documentation of this file.
1/*
2 MUTATION-MESSAGE.hpp - message to cause changes to generic model elements
3
4 Copyright (C)
5 2017, 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
81#ifndef LIB_DIFF_MUTATION_MESSAGE_H
82#define LIB_DIFF_MUTATION_MESSAGE_H
83
84
85#include "lib/error.hpp"
86#include "lib/iter-source.hpp"
89#include "lib/diff/gen-node.hpp"
90#include "lib/format-util.hpp"
91#include "lib/meta/util.hpp"
92
93#include <string>
94
95
96namespace lib {
97namespace diff{
98
99 using std::string;
100 using std::__and_;
101 using std::__not_;
105
106 using DiffStep = TreeDiffLanguage::DiffStep;
108
109
110
126 {
128
129 MutationMessage() = default;
136
142 explicit
143 MutationMessage(DiffSource* diffGenerationContext)
144 : _FrontEnd{DiffSource::build (diffGenerationContext)}
145 { }
146
152 MutationMessage(std::initializer_list<DiffStep> const&& ili)
153 : MutationMessage{iter_stl::snapshot (move(ili))}
154 { }
155
161 template<typename...ARGS>
162 MutationMessage(ARGS&& ...args)
163 : MutationMessage{ {std::forward<ARGS>(args)...} }
164 { }
165
170 template<class IT>
171 MutationMessage(IT&& ii, enable_if< can_IterForEach<IT>, void*> =nullptr)
172 : _FrontEnd{iter_source::wrapIter (std::forward<IT>(ii))}
173 { }
174
180 template<class CON>
181 MutationMessage(CON& container, enable_if< __and_< can_STL_ForEach<CON>
182 ,__not_<can_IterForEach<CON>>>, void*> =nullptr)
183 : _FrontEnd{iter_source::eachEntry(container)}
184 { }
185
186
194 MutationMessage& updateDiagnostics();
195 };
196
197
198
199 namespace { // Implementation: take snapshot to enable diagnostics
200
203 : std::vector<DiffStep>
204 {
206 {
207 for ( ; srcMsg; ++srcMsg )
208 push_back (*srcMsg);
209 }
210 };
211
212 using _VecIter = DiffSnapshot::iterator;
215
226 : private DiffSnapshot
227 , public _Wrapped
228 {
229 public:
231 : DiffSnapshot{srcMsg}
232 , _Wrapped{_RangeIT{DiffSnapshot::begin(), DiffSnapshot::end()}}
233 { }
234
235 virtual
236 operator string() const override
237 {
238 return "Diff--{"+util::join (static_cast<DiffSnapshot> (*this))+"}";
239 }
240 };
241 }
242
253 inline MutationMessage&
254 MutationMessage::updateDiagnostics()
255 {
256 return *this = MutationMessage{new MaterialisedDiffBuffer(*this)};
257 }
258
259
260
261
262
263}} // namespace lib::diff
264#endif /*LIB_DIFF_MUTATION_MESSAGE_H*/
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
Standard implementation of the IterSource interface: a wrapped "Lumiera Forward Iterator".
Decorator to be layered transparently on top of MutationMessage.
Trait template to detect a type usable immediately as "Lumiera Forward Iterator" in a specialised for...
Definition trait.hpp:511
Trait template to detect a type usable with the STL for-each loop.
Definition trait.hpp:556
Lumiera error handling (C++ interface).
Collection of small helpers and convenience shortcuts for diagnostics & formatting.
Generic building block for tree shaped (meta)data structures.
Preconfigured adapters for some STL container standard usage situations.
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
Simple and lightweight helpers for metaprogramming and type detection.
TreeDiffLanguage::DiffStep DiffStep
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Implementation namespace for support and library code.
STL namespace.
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
MutationMessage(ARGS &&...args)
Convenience builder to take an arbitrary number of DiffStep arguments.
MutationMessage(std::initializer_list< DiffStep > const &&ili)
Convenience builder for consuming an brace enclosed initializer_list.
MutationMessage(MutationMessage &&)=default
MutationMessage(MutationMessage &o)
MutationMessage(DiffSource *diffGenerationContext)
MutationMessage builder: take ownership of an opaque heap allocated context from which the concrete d...
MutationMessage(CON &container, enable_if< __and_< can_STL_ForEach< CON >, __not_< can_IterForEach< CON > > >, void * >=nullptr)
Convenience builder to use elements form any STL-like container.
MutationMessage(MutationMessage const &)=default
MutationMessage(IT &&ii, enable_if< can_IterForEach< IT >, void * >=nullptr)
Convenience builder to piggyback any Lumiera Forward Iterator.
MutationMessage & operator=(MutationMessage const &)=default
A token language to represent structural changes in a tree like hierarchical data structure.