50 using util::BOTTOM_INDICATOR;
53 using std::unique_ptr;
68 ATTRIB2(
"β", int64_t(2)),
74 CHILD_T(
Time(12,34,56,78)),
76 ATTRIB_NODE =
MakeRec().genNode(
"δ"),
77 GAMMA_PI(
"γ", 3.14159265);
89 string type_ = Rec::TYPE_NIL;
95 unique_ptr<Opaque> delta_;
97 vector<Opaque> nestedObj_;
98 vector<string> nestedData_;
122 , nestedObj_(o.nestedObj_)
123 , nestedData_(o.nestedData_)
126 delta_.reset(
new Opaque(*o.delta_));
130 operator= (
Opaque const& o)
140 bool verifyType(
string x)
const {
return x == type_; }
141 bool verifyAlpha(
int x)
const {
return x == alpha_;}
142 bool verifyBeta(int64_t x)
const {
return x == beta_; }
143 bool verifyGamma(
double x)
const {
return x == gamma_;}
144 bool verifyData(
string desc)
const {
return desc == join(nestedData_); }
145 const Opaque* nestedDelta()
const {
return not delta_? NULL : delta_.get(); }
146 const Opaque* nestedObj_1()
const {
return isnil(nestedObj_)? NULL : &nestedObj_[0]; }
149 operator string()
const 151 return _Fmt{
"%s__(α:%d β:%s γ:%7.5f δ:%s\n......|nested:%s\n......|data:%s\n )__END_%s"}
157 % join (nestedObj_,
"\n......|")
166 string symbol = key_.getSym() + (isTyped()?
"≺"+type_+
"≻" :
"");
167 return lib::idi::format::instance_hex_format(symbol, key_.getHash());
173 return Rec::TYPE_NIL != type_;
207 .isApplicableIf ([&](
GenNode const& spec) ->
bool 209 return not spec.isNamed();
211 .matchElement ([&](
GenNode const& spec,
string const& elm) ->
bool 213 return elm ==
render(spec.data);
215 .constructFrom ([&](
GenNode const& spec) ->
string 217 return render (spec.data);
219 .assignElement ([&](
string& target,
GenNode const& spec) ->
bool 221 target =
render (spec.data);
225 .isApplicableIf ([&](
GenNode const& spec) ->
bool 229 .matchElement ([&](
GenNode const& spec,
Opaque const& elm) ->
bool 231 return spec.idi == elm.key_;
242 .change(
"type", [&](
string typeID)
246 .change(
"α", [&](
int val)
250 .change(
"β", [&](int64_t val)
254 .change(
"γ", [&](
double val)
261 delta_.reset (
new Opaque(
"δ"));
264 delta_->buildMutator(buff);
272 friend constexpr
size_t 315 return snapshot({ins(ATTRIB1)
340 return snapshot({after(CHILD_B)
371 cout <<
"before..."<<endl << subject<<endl;
372 CHECK (subject.verifyAlpha(-1));
373 CHECK (subject.verifyBeta(-1));
374 CHECK (subject.verifyGamma(-1));
375 CHECK (not subject.nestedDelta());
376 CHECK (not subject.nestedObj_1());
377 CHECK (subject.verifyData(
""));
381 application.consume(populationDiff());
383 cout <<
"after...I"<<endl << subject<<endl;
385 CHECK (subject.verifyAlpha(1));
386 CHECK (subject.verifyGamma(ATTRIB3.data.get<
double>()));
387 CHECK (subject.verifyData(
"b, b, 78:56:34.012"));
389 CHECK (subject.verifyBeta(-1));
390 CHECK (not subject.nestedDelta());
391 CHECK (not subject.nestedObj_1());
395 application.consume(reorderingDiff());
397 cout <<
"after...II"<<endl << subject<<endl;
399 CHECK (subject.verifyAlpha(1));
400 CHECK (subject.verifyBeta (2));
401 CHECK (subject.verifyGamma(3.45));
402 CHECK (subject.verifyData(
"78:56:34.012, b"));
403 CHECK (subject.nestedObj_1());
404 CHECK (subject.nestedObj_1()->verifyType(Rec::TYPE_NIL));
405 CHECK (subject.nestedObj_1()->verifyBeta(-1));
406 CHECK (subject.nestedObj_1()->verifyData(
""));
410 application.consume(mutationDiff());
412 cout <<
"after...III"<<endl << subject<<endl;
417 CHECK (subject.verifyAlpha(1));
418 CHECK (subject.verifyBeta (2));
419 CHECK (subject.verifyGamma(GAMMA_PI.data.get<
double>()));
420 CHECK (subject.nestedDelta());
421 CHECK (subject.nestedDelta()->verifyType(
"ζ"));
422 CHECK (subject.nestedDelta()->verifyData(
"a, a, a"));
423 CHECK (subject.verifyData(
"78:56:34.012, b"));
424 CHECK (subject.nestedObj_1()->verifyType(
"ξ"));
425 CHECK (subject.nestedObj_1()->verifyBeta(2));
426 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_"
Simple 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.