diff --git a/tests/library/polymorphic-value-test.cpp b/tests/library/polymorphic-value-test.cpp index f64b72a5d..3371208f1 100644 --- a/tests/library/polymorphic-value-test.cpp +++ b/tests/library/polymorphic-value-test.cpp @@ -157,8 +157,8 @@ namespace test{ } - typedef PolymorphicValue PolyVal; - typedef std::vector TestList; + using PolyVal = PolymorphicValue; + using TestList = std::vector ; @@ -235,10 +235,10 @@ namespace test{ verifyCreation_and_Copy(); // Special case: client objects expose extension point for copy support - typedef polyvalue::CopySupport CopySupportAPI; // Copy support API declared as sub-interface - typedef Imp CopySupportingImp; // insert this sub-interface between public API and Implementation - typedef PolymorphicValue OptimalPolyVal; // Make the Holder use this special attachment point - CHECK (sizeof(OptimalPolyVal) < sizeof(PolyVal)); // results in smaller Holder and less implementation overhead + using CopySupportAPI = polyvalue::CopySupport; // Copy support API declared as sub-interface + using CopySupportingImp = Imp; // insert this sub-interface between public API and Implementation + using OptimalPolyVal = PolymorphicValue; // Make the Holder use this special attachment point + CHECK (sizeof(OptimalPolyVal) < sizeof(PolyVal)); // results in smaller Holder and less implementation overhead verifyCreation_and_Copy(); } @@ -248,9 +248,9 @@ namespace test{ void verifyCreation_and_Copy() { - typedef PV Holder; - typedef IMP ImpType; - typedef typename PV::Interface Api; + using Holder = PV; + using ImpType = IMP; + using Api = typename PV::Interface ; long prevSum = _checkSum; uint prevCnt = _created; @@ -260,13 +260,13 @@ namespace test{ CHECK (prevCnt+1 <= _created); // Note: usually, the compiler optimises CHECK (prevCnt+2 >= _created); // and skips the spurious copy-operation CHECK (sizeof(Holder) >= sizeof(ImpType)); - Api& embedded = val; - CHECK (isSameObject(embedded,val)); - CHECK (INSTANCEOF(ImpType, &embedded)); + Api& api = val; + CHECK (isSameObject(api,val)); + CHECK (INSTANCEOF(ImpType, &api)); prevCnt = _created; Holder val2(val); // invoke copy ctor without knowing the implementation type - embedded.apiFunc(); + api.apiFunc(); CHECK (val != val2); // invoking the API function had an sideeffect on the state val = val2; // assignment of copy back to the original... CHECK (val == val2); // cancels the side effect diff --git a/tests/vault/gear/test-chain-load-test.cpp b/tests/vault/gear/test-chain-load-test.cpp index 01a549c31..41e1eef62 100644 --- a/tests/vault/gear/test-chain-load-test.cpp +++ b/tests/vault/gear/test-chain-load-test.cpp @@ -176,13 +176,14 @@ namespace test { CHECK (0 == graph.getSeed()); CHECK (0 == graph.getHash()); + ///////////////////////////////////////////////////////////////////////TODO : what follows is WIP to test the DOT graph generator.... using N = TestChainLoad<>::Node; std::array n; n[1].addPred(n[0]); n[2].addPred(n[0]); n[3].addPred(n[1]); n[3].addPred(n[2]); - n[4].addPred(n[1]); + n[5].addPred(n[1]); n[6].addPred(n[3]); n[6].addPred(n[4]); n[6].addPred(n[5]); @@ -199,7 +200,7 @@ namespace test { Code TOP {"shape=box, style=rounded"}; Code DEFAULT{}; - auto nNr = [&](N& nn){ return size_t(&nn - &n[0]); }; + auto nNr = [&](N& nn){ return size_t(&nn - &n[0]); }; for (N& nn : n) { size_t i = nNr(nn); @@ -210,10 +211,10 @@ namespace test { for (N* suc : nn.succ) topology += connect(i, nNr(*suc)); } - layers += scope(0) + Node(0) + rankMIN(); - layers += scope(1) + Node(1) + Node(2); - layers += scope(2) + Node(3) + Node(4) + Node(5); - layers += scope(3) + Node(6); + layers += Scope(0).rank("min ").add(Node(0)); + layers += Scope(1).rank("same").add(Node(1)).add(Node(2)); + layers += Scope(2).rank("same").add(Node(3)).add(Node(4)).add(Node(5)); + layers += Scope(3).rank("same").add(Node(6)); cout << digraph(nodes,layers,topology) < #include #include //#include //#include -//#include -#include -#include #include +#include /////////////////TODO used only for dot generation +#include +#include /////////////////TODO used only for dot generation #include @@ -108,7 +108,8 @@ namespace test { // using lib::time::FSecs; // using lib::time::Offset; // using lib::meta::RebindVariadic; -// using util::isnil; + using util::toString; /////////////////TODO used only for dot generation + using util::isnil; /////////////////TODO used only for dot generation using util::max; using util::unConst; // using std::forward; @@ -130,6 +131,29 @@ namespace test { namespace dot { + struct Code : string + { + using string::string; + Code(string const& c) : string{c} { } + Code(string && c) : string{move(c)}{ } + }; + + struct Section + { + std::vector lines; + + Section (string name) + : lines{"// "+name} + { } + + Section&& + operator+= (Code&& code) + { + lines.emplace_back(move (code)); + return move(*this); + } + }; + /** * Helper to generate DOT-Graphviz rendering of topology */ @@ -137,84 +161,120 @@ namespace test { { std::ostringstream buff_; + static uint const IDENT_STEP = 2; public: - - operator string() const { return buff_.str(); } - }; - - struct Code - { - Code (string code ="") + void + putLine (string line, uint indent=0) { - + if (indent) + buff_ << string(indent,' '); + buff_ << line + << '\n'; } - Code&& - operator+= (Code&& c) + void + put (Code const& code) { - + buff_ << code; } - Code&& - operator+ (Code&& c) + void + put (Section const& sect) { - + for (string const& line : sect.lines) + putLine (line, IDENT_STEP); } - }; - - struct Section : Code - { - Section(string name) + + template + void + put (P const& part, PS const& ...parts) { - + put (part); + putLine (""); + put (parts...); + } + + /** retrieve complete code generated thus far */ + operator string() const + { + return buff_.str(); } }; struct Node : Code { Node (size_t id) - { - - } + : Code{"N"+toString(id)} + { } + Node&& - label(size_t i) + addAttrib (string def) { + if (back() != ']') + append ("["); + else + { + resize (length()-2); + append (", "); + } + append (def+" ]"); return move(*this); } + Node&& - style(Code code) + label (size_t i) { + return addAttrib ("label="+toString(i)); + } + + Node&& + style (Code const& code) + { + if (not isnil(code)) + addAttrib (code); return move(*this); } }; - inline Code - scope (size_t id) - { - - } - inline Code - rankMIN() - { - - } + struct Scope : Code + { + Scope (size_t id) + : Code{"{ /*"+toString(id)+"*/ }"} + { } + + Scope&& + add (Code const& code) + { + resize(length()-1); + append (code+" }"); + return move(*this); + } + + Scope&& + rank (string rankSetting) + { + return add(Code{"rank="+rankSetting}); + } + }; inline Code connect (size_t src, size_t dest) { - + return Code{Node(src) +" -> "+ Node(dest)}; } template inline DotOut digraph (COD ...parts) { - + DotOut script; + script.putLine (Code{"digraph {"}); + script.put (parts...); + script.putLine (Code{"}"}); + return script; } -//////////////////////////////////////////// -//////////////////////////////////////////// } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 2103875e8..7deac39ae 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -95850,6 +95850,20 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + + + + + @@ -95999,7 +96013,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + @@ -96026,8 +96041,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - +
@@ -96120,8 +96134,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
}

- - + @@ -96132,8 +96145,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
rank muß explizit in jedem Layer definiert sein

- - +
@@ -96144,8 +96156,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
...und das zeigt sich in schwer verständlichem Fehlverhalten; er macht dann Nodes mehrfach...

- - +
@@ -96185,8 +96196,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
     .end();

- - +
@@ -96213,8 +96223,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
      term("x"))))

- - +
@@ -96241,8 +96250,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
      dsl.term("x"))))

- - +
@@ -96290,16 +96298,17 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
  process(myContext);

- - +
- + - + + + @@ -96307,6 +96316,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + @@ -96334,8 +96347,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
nur bodenständige Performance....

- - +
@@ -96344,15 +96356,62 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ ...aber sage erst mal YAGNI +

+ + +
+
+ + + + + + + + +

+ ...man könnte z.B. meinen PolymorphicValue verwenden (wenn ich mich nur + nicht so für den verworrenen Implementierungs-Code schämen müßte... �� + Ticket #1197) +

+ +
+ +
+
+
+ + - - - - @@ -103755,8 +103814,7 @@ class Something bottom to top

- - +