From 53ac1911e7954b8a0c8c399cc3bf8d183d052338 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 3 Nov 2024 23:58:25 +0100 Subject: [PATCH] Invocation: render a processing-spec for a port --- src/lib/symbol-impl.cpp | 2 +- src/steam/engine/proc-id.hpp | 10 +++--- src/steam/engine/proc-node.cpp | 34 +++++++++++++++--- tests/core/steam/engine/node-linkage-test.cpp | 4 +++ .../core/steam/engine/test-rand-ontology.cpp | 2 +- wiki/thinkPad.ichthyo.mm | 36 +++++++++---------- 6 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/lib/symbol-impl.cpp b/src/lib/symbol-impl.cpp index f3044610f..ccf733562 100644 --- a/src/lib/symbol-impl.cpp +++ b/src/lib/symbol-impl.cpp @@ -118,7 +118,7 @@ namespace lib { size_t cnt = 1; const char *pos = literal; for ( ; cnt <= STRING_MAX_RELEVANT and *pos ; ++cnt, ++pos ) - hash_combine(hash, *pos); + hash_combine (hash, *pos); } return hash; diff --git a/src/steam/engine/proc-id.hpp b/src/steam/engine/proc-id.hpp index 110bcc0b4..2ea7c5f19 100644 --- a/src/steam/engine/proc-id.hpp +++ b/src/steam/engine/proc-id.hpp @@ -70,11 +70,8 @@ namespace engine { /* === symbolic descriptors === */ - string - genProcSpec() - { - return "Lalü"; - } + string genProcSpec(); ///< render a descriptor for the operation (without predecessors) + friend bool operator== (ProcID const& l, ProcID const& r) @@ -87,9 +84,10 @@ namespace engine { friend bool operator!= (ProcID const& l, ProcID const& r) { return not (l == r); } + + friend HashVal hash_value (ProcID const&); }; - HashVal hash_value (ProcID const&); diff --git a/src/steam/engine/proc-node.cpp b/src/steam/engine/proc-node.cpp index 9db39a554..117c3c0d0 100644 --- a/src/steam/engine/proc-node.cpp +++ b/src/steam/engine/proc-node.cpp @@ -40,7 +40,11 @@ namespace steam { namespace engine { + using util::_Fmt; + using util::isnil; using util::unConst; + using util::contains; + using boost::hash_combine; namespace { // Details... @@ -62,7 +66,16 @@ namespace engine { ProcID& ProcID::describe (StrView nodeSymb, StrView portSpec) { - auto res = procRegistry.insert (ProcID{"bla","blubb","murks"}); + REQUIRE (not isnil (nodeSymb)); + REQUIRE (not isnil (portSpec)); + REQUIRE (not contains (nodeSymb, ' ')); + auto p = portSpec.find('('); + if (p == string::npos) + throw err::Invalid{_Fmt{"Spec for processing operation must contain at least one argument list. " + "Node:%s Spec:%s"} + % nodeSymb % portSpec + }; + auto res = procRegistry.insert (ProcID{nodeSymb, portSpec.substr(0,p), portSpec.substr(p)}); return unConst (*res.first); } @@ -80,9 +93,22 @@ namespace engine { HashVal hash_value (ProcID const& procID) { - return 47; //UNIMPLEMENTED ("ProcID hash"); + HashVal hash = boost::hash_value (procID.nodeSymb_); + if (not isnil(procID.portQual_)) + hash_combine (hash, procID.portQual_); + hash_combine (hash, procID.argLists_); + return hash; } + string + ProcID::genProcSpec() + { + return nodeSymb_ + + (isnil(portQual_)? string{} : "."+portQual_) + + argLists_; + } + + string ProcNodeDiagnostic::getNodeSpec() @@ -104,8 +130,8 @@ namespace engine { ProcNodeDiagnostic::getPortSpec (uint portIdx) { auto& p{n_.wiring_.ports}; - return p.size() < portIdx? util::FAILURE_INDICATOR - : p[portIdx].procID.genProcSpec(); + return portIdx < p.size()? p[portIdx].procID.genProcSpec() + : util::FAILURE_INDICATOR; } HashVal diff --git a/tests/core/steam/engine/node-linkage-test.cpp b/tests/core/steam/engine/node-linkage-test.cpp index b860222de..14d53ba3a 100644 --- a/tests/core/steam/engine/node-linkage-test.cpp +++ b/tests/core/steam/engine/node-linkage-test.cpp @@ -35,6 +35,7 @@ using util::isnil; //using std::string; +using util::isSameObject; namespace steam { @@ -85,6 +86,9 @@ namespace test { CHECK (watch(n1).leads().empty()); CHECK (watch(n1).ports().size() == 1); SHOW_EXPR(watch(n1).getPortSpec(0)) + CHECK (watch(n1).getPortSpec(0) == "Test:Src.dummyFun(TestFrame)"_expect); +SHOW_EXPR(watch(n1).getPortSpec(1)) + CHECK (watch(n1).getPortSpec(1) == "↯"_expect); } diff --git a/tests/core/steam/engine/test-rand-ontology.cpp b/tests/core/steam/engine/test-rand-ontology.cpp index 9011a1b93..c203376f8 100644 --- a/tests/core/steam/engine/test-rand-ontology.cpp +++ b/tests/core/steam/engine/test-rand-ontology.cpp @@ -42,7 +42,7 @@ namespace test { } // (End) hidden impl details - const string DUMMY_FUN_ID{"DummyFun"}; + const string DUMMY_FUN_ID{"dummyFun(TestFrame)"}; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 2493c6bbe..568715a59 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -91052,9 +91052,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - + + + @@ -91381,8 +91381,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -91393,24 +91393,24 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - - - + + + + + - - + + - - + + @@ -91691,8 +91691,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
Beschluß: als string_view durch den Builder durchreichen

- - + @@ -91706,14 +91705,13 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
das heißt, es handelt sich definitiv nicht um Literal-Strings; zudem wollen wir die Spec ggfs. noch zerlegen und dann in eine Symbol-Table internen; insofern ist std::string_view der naheliegende Ansatz, da wir keine Inline-Storage durch x-fache Builder-Objekte durchschieben wollen, bloß um am Ende doch nur einen Teilstring in die Symboltabelle zu kopieren

- - +
- +