From 55ad44590c582d86cd8a6d8ca349164d238404cc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 11 Jan 2025 22:17:07 +0100 Subject: [PATCH] Invocation: cover dissecting of ProcID spec ..with some slight changes * also recognise domain prefix * omit domain prefix in proc-name --- src/steam/engine/proc-id.hpp | 7 ++- src/steam/engine/proc-node.cpp | 51 ++++++++++++++++------ tests/core/steam/engine/node-meta-test.cpp | 24 ++++++++-- wiki/thinkPad.ichthyo.mm | 6 +++ 4 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/steam/engine/proc-id.hpp b/src/steam/engine/proc-id.hpp index e5a2af852..2d6d4b9bf 100644 --- a/src/steam/engine/proc-id.hpp +++ b/src/steam/engine/proc-id.hpp @@ -109,7 +109,7 @@ namespace engine { */ class ProcID { - StrView nodeSymb_; + StrView nodeName_; StrView portQual_; StrView argLists_; ProcAttrib attrib_{}; @@ -127,14 +127,17 @@ namespace engine { string genProcName(); string genProcSpec(); ///< render a descriptor for the operation (without predecessors) + string genQualifier(); string genNodeName(); + string genNodeSymbol(); + string genNodeDomain(); string genNodeSpec(Leads&); string genSrcSpec (Leads&); ///< transitively enumerate all unique source nodes friend bool operator== (ProcID const& l, ProcID const& r) { - return l.nodeSymb_ == r.nodeSymb_ + return l.nodeName_ == r.nodeName_ and l.portQual_ == r.portQual_ and l.argLists_ == r.argLists_ and l.attrib_ == r.attrib_; diff --git a/src/steam/engine/proc-node.cpp b/src/steam/engine/proc-node.cpp index 77dead69b..3d91fc191 100644 --- a/src/steam/engine/proc-node.cpp +++ b/src/steam/engine/proc-node.cpp @@ -81,7 +81,7 @@ namespace engine { ProcID& entry{unConst (*res.first)}; if (res.second) {// new record placed into the registry - dedupSymbol (entry.nodeSymb_); + dedupSymbol (entry.nodeName_); dedupSymbol (entry.argLists_); if (not isnil(entry.portQual_)) dedupSymbol (entry.portQual_); @@ -91,7 +91,7 @@ namespace engine { /** @internal */ ProcID::ProcID (StrView nodeSymb, StrView portQual, StrView argLists) - : nodeSymb_{nodeSymb} + : nodeName_{nodeSymb} , portQual_{portQual} , argLists_{argLists} { } @@ -104,7 +104,7 @@ namespace engine { HashVal hash_value (ProcID const& procID) { - HashVal hash = boost::hash_value (procID.nodeSymb_); ///////////////////////////////////////////////////TICKET #1391 : which technology to use for processing-ID hashes -> cache keys? + HashVal hash = boost::hash_value (procID.nodeName_); ///////////////////////////////////////////////////TICKET #1391 : which technology to use for processing-ID hashes -> cache keys? if (not isnil(procID.portQual_)) hash_combine (hash, procID.portQual_); ////////////////////////////////////////////////////////TICKET #1391 : should use lib/hash-combine.hpp (stable, but not portable!) hash_combine (hash, procID.argLists_); @@ -115,9 +115,8 @@ namespace engine { ProcID::genProcName() { std::ostringstream buffer; - buffer << nodeSymb_; - if (not isnil(portQual_)) - buffer << '.' << portQual_; + buffer << genNodeSymbol() + << genQualifier(); return buffer.str(); } @@ -125,17 +124,41 @@ namespace engine { ProcID::genProcSpec() { std::ostringstream buffer; - buffer << nodeSymb_; - if (not isnil(portQual_)) - buffer << '.' << portQual_; - buffer << argLists_; + buffer << nodeName_ + << genQualifier() + << argLists_; return buffer.str(); } string ProcID::genNodeName() { - return string{nodeSymb_}; + return string{nodeName_}; + } + + string + ProcID::genNodeSymbol() + { + auto p = nodeName_.find(':'); + return p == string::npos? string{nodeName_} + : string{nodeName_.substr(p+1)}; + } + + string + ProcID::genNodeDomain() + { + auto p = nodeName_.find(':'); + return p == string::npos? string{} + : string{nodeName_.substr(0,p)}; + } + + string + ProcID::genQualifier() + { + std::ostringstream buffer; + if (not isnil(portQual_)) + buffer << '.' << portQual_; + return buffer.str(); } @@ -152,7 +175,7 @@ namespace engine { ProcID::genNodeSpec (Leads& leads) { std::ostringstream buffer; - buffer << nodeSymb_; + buffer << nodeName_; if (1 != leads.size()) buffer << genSrcSpec(leads); else @@ -174,7 +197,7 @@ namespace engine { explore(leads) .expandAll([](ProcNode& n){ return explore(watch(n).leads()); }) // depth-first expand all predecessors .filter ([](ProcNode& n){ return watch(n).isSrc(); }) // but retain only leafs (≙ source nodes) - .transform([](ProcNode& n){ return procID(n).nodeSymb_;}) // render the node-symbol of each src + .transform([](ProcNode& n){ return procID(n).nodeName_;}) // render the node-symbol of each src .deduplicate()) // sort and deduplicate + "}"; } @@ -231,7 +254,7 @@ namespace engine { string PortDiagnostic::getProcSpec() { - p_.procID.genProcSpec(); + return p_.procID.genProcSpec(); } HashVal diff --git a/tests/core/steam/engine/node-meta-test.cpp b/tests/core/steam/engine/node-meta-test.cpp index 070a1e6df..7e541859e 100644 --- a/tests/core/steam/engine/node-meta-test.cpp +++ b/tests/core/steam/engine/node-meta-test.cpp @@ -50,14 +50,32 @@ namespace test { /** @test TODO evaluation of processing-spec for a ProcID - * @todo WIP 1/25 🔁 define ⟶ implement + * @todo WIP 1/25 🔁 define ⟶ 🔁 implement */ void verify_ID_specification() { auto& p1 = ProcID::describe("N1","(arg)"); - auto& p2 = ProcID::describe("N1","(a1,a2)"); - auto& p3 = ProcID::describe("N1","(in/3)(o1,o2/2)"); + auto& p2 = ProcID::describe("U:N2","+(a1,a2)"); + auto& p3 = ProcID::describe("O:N3","(in/3)(o1,o2/2)"); + + CHECK (p1.genNodeName() == "N1"_expect ); + CHECK (p1.genNodeSymbol() == "N1"_expect ); + CHECK (p1.genNodeDomain() == ""_expect ); + CHECK (p2.genNodeName() == "U:N2"_expect ); + CHECK (p2.genNodeSymbol() == "N2"_expect ); + CHECK (p2.genNodeDomain() == "U"_expect ); + CHECK (p3.genNodeName() == "O:N3"_expect ); + CHECK (p3.genNodeSymbol() == "N3"_expect ); + CHECK (p3.genNodeDomain() == "O"_expect ); + + CHECK (p1.genProcName() == "N1"_expect ); + CHECK (p1.genQualifier() == ""_expect ); + CHECK (p2.genProcName() == "N2.+"_expect ); // domain omitted, qualifier joined with '.' + CHECK (p2.genQualifier() == ".+"_expect ); // qualifier includes leading '.' + CHECK (p3.genProcName() == "N3"_expect ); + CHECK (p2.genProcSpec() == "U:N2.+(a1,a2)"_expect ); + CHECK (p3.genProcSpec() == "O:N3(in/3)(o1,o2/2)"_expect ); UNIMPLEMENTED ("parse and evaluate"); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 4f7969983..88673074f 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -102421,6 +102421,12 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + +