41 using util::BOTTOM_INDICATOR;
44 using std::unique_ptr;
59 ATTRIB2(
"β", int64_t(2)),
65 CHILD_T(
Time(12,34,56,78)),
67 ATTRIB_NODE =
MakeRec().genNode(
"δ"),
68 GAMMA_PI(
"γ", 3.14159265);
80 string type_ = Rec::TYPE_NIL;
86 unique_ptr<Opaque> delta_;
88 vector<Opaque> nestedObj_;
89 vector<string> nestedData_;
113 , nestedObj_(o.nestedObj_)
114 , nestedData_(o.nestedData_)
117 delta_.reset(
new Opaque(*o.delta_));
121 operator= (
Opaque const& o)
131 bool verifyType(
string x)
const {
return x == type_; }
132 bool verifyAlpha(
int x)
const {
return x == alpha_;}
133 bool verifyBeta(int64_t x)
const {
return x == beta_; }
134 bool verifyGamma(
double x)
const {
return x == gamma_;}
135 bool verifyData(
string desc)
const {
return desc == join(nestedData_); }
136 const Opaque* nestedDelta()
const {
return not delta_? NULL : delta_.get(); }
137 const Opaque* nestedObj_1()
const {
return isnil(nestedObj_)? NULL : &nestedObj_[0]; }
140 operator string()
const 142 return _Fmt{
"%s__(α:%d β:%s γ:%7.5f δ:%s\n......|nested:%s\n......|data:%s\n )__END_%s"}
148 % join (nestedObj_,
"\n......|")
157 string symbol = key_.getSym() + (isTyped()?
"≺"+type_+
"≻" :
"");
158 return lib::idi::format::instance_hex_format(symbol, key_.getHash());
164 return Rec::TYPE_NIL != type_;
198 .isApplicableIf ([&](
GenNode const& spec) ->
bool 200 return not spec.isNamed();
202 .matchElement ([&](
GenNode const& spec,
string const& elm) ->
bool 204 return elm ==
render(spec.data);
206 .constructFrom ([&](
GenNode const& spec) ->
string 208 return render (spec.data);
210 .assignElement ([&](
string& target,
GenNode const& spec) ->
bool 212 target =
render (spec.data);
216 .isApplicableIf ([&](
GenNode const& spec) ->
bool 220 .matchElement ([&](
GenNode const& spec,
Opaque const& elm) ->
bool 222 return spec.idi == elm.key_;
233 .change(
"type", [&](
string typeID)
237 .change(
"α", [&](
int val)
241 .change(
"β", [&](int64_t val)
245 .change(
"γ", [&](
double val)
252 delta_.reset (
new Opaque(
"δ"));
255 delta_->buildMutator(buff);
263 friend constexpr
size_t 306 return snapshot({ins(ATTRIB1)
331 return snapshot({after(CHILD_B)
362 cout <<
"before..."<<endl << subject<<endl;
363 CHECK (subject.verifyAlpha(-1));
364 CHECK (subject.verifyBeta(-1));
365 CHECK (subject.verifyGamma(-1));
366 CHECK (not subject.nestedDelta());
367 CHECK (not subject.nestedObj_1());
368 CHECK (subject.verifyData(
""));
372 application.consume(populationDiff());
374 cout <<
"after...I"<<endl << subject<<endl;
376 CHECK (subject.verifyAlpha(1));
377 CHECK (subject.verifyGamma(ATTRIB3.data.get<
double>()));
378 CHECK (subject.verifyData(
"b, b, 78:56:34.012"));
380 CHECK (subject.verifyBeta(-1));
381 CHECK (not subject.nestedDelta());
382 CHECK (not subject.nestedObj_1());
386 application.consume(reorderingDiff());
388 cout <<
"after...II"<<endl << subject<<endl;
390 CHECK (subject.verifyAlpha(1));
391 CHECK (subject.verifyBeta (2));
392 CHECK (subject.verifyGamma(3.45));
393 CHECK (subject.verifyData(
"78:56:34.012, b"));
394 CHECK (subject.nestedObj_1());
395 CHECK (subject.nestedObj_1()->verifyType(Rec::TYPE_NIL));
396 CHECK (subject.nestedObj_1()->verifyBeta(-1));
397 CHECK (subject.nestedObj_1()->verifyData(
""));
401 application.consume(mutationDiff());
403 cout <<
"after...III"<<endl << subject<<endl;
408 CHECK (subject.verifyAlpha(1));
409 CHECK (subject.verifyBeta (2));
410 CHECK (subject.verifyGamma(GAMMA_PI.data.get<
double>()));
411 CHECK (subject.nestedDelta());
412 CHECK (subject.nestedDelta()->verifyType(
"ζ"));
413 CHECK (subject.nestedDelta()->verifyData(
"a, a, a"));
414 CHECK (subject.verifyData(
"78:56:34.012, b"));
415 CHECK (subject.nestedObj_1()->verifyType(
"ξ"));
416 CHECK (subject.nestedObj_1()->verifyBeta(2));
417 CHECK (subject.nestedObj_1()->verifyData(
"b, a"));
Concrete implementation to apply structural changes to hierarchical data structures.
type erased baseclass for building a combined hash and symbolic ID.
string render(DataCap const &)
bool isNested() const
determine if payload constitutes a nested scope ("object")
void buildMutator(TreeMutator::Handle buff)
the only way this opaque object exposes itself for mutation through diff messages.
opaque private data structure to apply the diff.
typed symbolic and hash ID for asset-like position accounting.
iter_stl::IterSnapshot< VAL > snapshot(std::initializer_list< VAL > const &&ili)
Take a snapshot of the given std::initializer_list.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
static Builder< TreeMutator > build()
DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrapp...
SUB & emplace(SUB &&implementation)
move-construct an instance of a subclass into the opaque buffer
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
static const Ref END
symbolic ID ref "_END_"
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
materialised iterator contents.
auto collection(COLL &coll)
Entry point to a nested DSL for setup and configuration of a collection binding.
Preconfigured adapters for some STL container standard usage situations.
a family of time value like entities and their relationships.
friend constexpr size_t treeMutatorSize(const Opaque *)
override default size traits to allow for sufficient buffer, able to hold the mutator defined above...
Diagnostic helper for unit tests regarding mutation of custom data.
generic data element node within a tree
generic builder to apply a diff description to a given target data structure.