Invocation: implement deduplication of spec strings

* verify hash and identity of the generated `ProcID` records
 * also verify format of the generated Proc-Spec for a `Turnout`
This commit is contained in:
Fischlurch 2024-11-04 01:04:01 +01:00
parent 53ac1911e7
commit 85e2966975
4 changed files with 92 additions and 41 deletions

View file

@ -58,9 +58,9 @@ namespace engine {
class ProcID
{
string nodeSymb_;
string portQual_;
string argLists_;
StrView nodeSymb_;
StrView portQual_;
StrView argLists_;
ProcID (StrView nodeSymb, StrView portQual, StrView argLists);

View file

@ -49,7 +49,14 @@ namespace engine {
namespace { // Details...
std::unordered_set<ProcID> procRegistry;
std::unordered_set<string> symbRegistry;
void inline
dedupSymbol (StrView& symbol)
{
auto res = symbRegistry.emplace (symbol);
symbol = *res.first;
}
} // (END) Details...
@ -76,7 +83,15 @@ namespace engine {
% nodeSymb % portSpec
};
auto res = procRegistry.insert (ProcID{nodeSymb, portSpec.substr(0,p), portSpec.substr(p)});
return unConst (*res.first);
ProcID& entry{unConst (*res.first)};
if (res.second)
{// new record placed into the registry
dedupSymbol (entry.nodeSymb_);
dedupSymbol (entry.argLists_);
if (not isnil(entry.portQual_))
dedupSymbol (entry.portQual_);
}
return entry;
}
/** @internal */
@ -103,9 +118,12 @@ namespace engine {
string
ProcID::genProcSpec()
{
return nodeSymb_
+ (isnil(portQual_)? string{} : "."+portQual_)
+ argLists_;
std::ostringstream buffer;
buffer << nodeSymb_;
if (not isnil(portQual_))
buffer << '.' << portQual_;
buffer << argLists_;
return buffer.str();
}

View file

@ -86,9 +86,32 @@ namespace test {
CHECK (watch(n1).leads().empty());
CHECK (watch(n1).ports().size() == 1);
SHOW_EXPR(watch(n1).getPortSpec(0))
// can generate a symbolic spec to describe the Port's processing functionality...
CHECK (watch(n1).getPortSpec(0) == "Test:Src.dummyFun(TestFrame)"_expect);
SHOW_EXPR(watch(n1).getPortSpec(1))
CHECK (watch(n1).getPortSpec(1) == ""_expect);
// such a symbolic spec is actually generated by a deduplicated metadata descriptor
auto& meta1 = ProcID::describe("N1","(arg)");
auto& meta1b = ProcID::describe("N1","(arg)");
auto& meta2 = ProcID::describe("N2","(arg)");
auto& meta3 = ProcID::describe("N1","uga()");
CHECK ( isSameObject (meta1,meta1b));
CHECK (not isSameObject (meta1,meta2));
CHECK (not isSameObject (meta1,meta3));
CHECK (hash_value(meta1) == hash_value(meta1b));
CHECK (hash_value(meta1) != hash_value(meta2));
CHECK (hash_value(meta1) != hash_value(meta3));
SHOW_EXPR(meta1.genProcSpec());
CHECK (meta1.genProcSpec() == "N1(arg)"_expect);
SHOW_EXPR(meta2.genProcSpec());
CHECK (meta2.genProcSpec() == "N2(arg)"_expect);
SHOW_EXPR(meta3.genProcSpec());
CHECK (meta3.genProcSpec() == "N1.uga()"_expect);
auto& metaN1 = ProcID::describe("Test:Src",DUMMY_FUN_ID);
SHOW_EXPR(metaN1.genProcSpec());
CHECK (metaN1.genProcSpec() == "Test:Src.dummyFun(TestFrame)"_expect);
}

View file

@ -13676,9 +13676,7 @@
</node>
<node COLOR="#338800" CREATED="1518312817798" ID="ID_473624624" MODIFIED="1518487921069">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
Schreibweise f&#252;r <i>create Clauses</i>
@ -15400,9 +15398,7 @@
</node>
<node BACKGROUND_COLOR="#ccb59b" COLOR="#6e2a38" CREATED="1523746600925" HGAP="1" ID="ID_435582808" MODIFIED="1523746656723" VSHIFT="36">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
Das urspr&#252;ngliche Ziel f&#252;r diesen Test
@ -17417,9 +17413,7 @@
</node>
<node CREATED="1504371342426" ID="ID_869653682" MODIFIED="1557498707222">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
vermittelt &#252;ber den <b>ViewLocator</b>&#160;(InteractionDirector)
@ -19654,9 +19648,7 @@
<node CREATED="1665871377691" ID="ID_1824259652" MODIFIED="1665871382745" TEXT="ein Inhalts-Handle">
<node CREATED="1665871386532" ID="ID_647005980" MODIFIED="1665871407866">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
weil ElementBoxWidget selbst keine <i>&quot;business logic&quot; </i>bereitstellt
@ -47022,9 +47014,7 @@
</node>
<node CREATED="1535723351533" ID="ID_909635517" MODIFIED="1535723375219">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
aber die Operationen sind <i>der Sache nach</i>&#160;nicht symmetrisch
@ -47873,9 +47863,7 @@
</node>
<node CREATED="1457231727259" ID="ID_1318527107" MODIFIED="1575133326776">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
<font color="#e72d0e">warning:</font>&#160;messed-up state in case of failure
@ -48155,9 +48143,7 @@
<node CREATED="1456012585835" ID="ID_1377280414" MODIFIED="1456012605260" TEXT="Mutator im Inline-Puffer"/>
<node CREATED="1456012665681" ID="ID_227844194" MODIFIED="1575133327718" TEXT="Gr&#xf6;&#xdf;e initial festlegen">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
...denn in dem Moment, wo wir den top-level TreeMutator erzeugen,
@ -48394,9 +48380,7 @@
<node CREATED="1456426041626" FOLDED="true" ID="ID_101262346" MODIFIED="1561827482931" TEXT="Duplikation">
<node CREATED="1456425918071" ID="ID_18884187" MODIFIED="1456437520772" TEXT="DOM-IDs am Binde-Punkt">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<head/>
<body>
<p>
um den Binde- bzw. Ankn&#252;pfungs-Punkt in den real-Daten &#252;berhaupt zu finden,
@ -48662,9 +48646,7 @@
</node>
<node CREATED="1475355960899" ID="ID_1468155641" MODIFIED="1518487921087">
<richcontent TYPE="NODE"><html>
<head>
</head>
<head/>
<body>
<p>
Marker-Typ <b>MutationMessage</b>
@ -91403,6 +91385,10 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="button_ok"/>
</node>
</node>
<node COLOR="#338800" CREATED="1730685853457" ID="ID_1442841929" MODIFIED="1730685940903" TEXT="auch die deduplizierte ProcID mit ein paar Tests dokumentiert">
<arrowlink COLOR="#699598" DESTINATION="ID_1508089317" ENDARROW="Default" ENDINCLINATION="570;33;" ID="Arrow_ID_1819595565" STARTARROW="None" STARTINCLINATION="287;13;"/>
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1728785867907" ID="ID_394739045" MODIFIED="1730682037506" TEXT="Spec generieren">
<icon BUILTIN="pencil"/>
@ -91783,10 +91769,10 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1730598253584" ID="ID_763084379" MODIFIED="1730598384398" TEXT="wird in einer Registry abgelegt">
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#435e98" CREATED="1730598253584" ID="ID_763084379" MODIFIED="1730685954764" TEXT="wird in einer Registry abgelegt">
<icon BUILTIN="messagebox_warning"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1730598263877" ID="ID_973341461" MODIFIED="1730670933336" TEXT="vorerst einfach statisch implementieren">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1730598263877" ID="ID_973341461" MODIFIED="1730685945952" TEXT="vorerst einfach statisch implementieren">
<icon BUILTIN="button_ok"/>
<node CREATED="1730669112939" ID="ID_887683968" MODIFIED="1730669137232" TEXT="Annahme: keine Concurrency">
<icon BUILTIN="yes"/>
</node>
@ -91803,7 +91789,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</body>
</html></richcontent>
</node>
<node CREATED="1730669238465" ID="ID_645344682" MODIFIED="1730671822014" TEXT="sinnvollerweise auch die Teil-Strings ebenfalls in so eine Symboltabelle legen">
<node COLOR="#338800" CREATED="1730669238465" ID="ID_645344682" MODIFIED="1730685884978" TEXT="sinnvollerweise auch die Teil-Strings ebenfalls in so eine Symboltabelle legen">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
@ -91813,7 +91799,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</body>
</html></richcontent>
</node>
<node CREATED="1730669278148" ID="ID_98610288" MODIFIED="1730669343276" TEXT="Implementierung: unordered_set + hash_value(Elm const&amp;)">
<node COLOR="#338800" CREATED="1730669278148" ID="ID_98610288" MODIFIED="1730685811979" TEXT="Implementierung: unordered_set + hash_value(Elm const&amp;)">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
@ -91826,8 +91812,12 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</body>
</html></richcontent>
</node>
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#435e98" CREATED="1730685817605" ID="ID_1508089317" MODIFIED="1730685940903" TEXT="korrekte Deduplikation im Debugger beobachtet">
<linktarget COLOR="#699598" DESTINATION="ID_1508089317" ENDARROW="Default" ENDINCLINATION="570;33;" ID="Arrow_ID_1819595565" SOURCE="ID_1442841929" STARTARROW="None" STARTINCLINATION="287;13;"/>
<icon BUILTIN="ksmiletris"/>
</node>
<node CREATED="1730598272422" ID="ID_74408441" MODIFIED="1730669177907" TEXT="keine Bereinigung vorsehen">
</node>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1730598272422" ID="ID_74408441" MODIFIED="1730685961355" TEXT="keine Bereinigung vorsehen">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
@ -91841,7 +91831,27 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1730598439357" ID="ID_1991416239" MODIFIED="1730598480466" TEXT="Deskriptoren und Hash-Keys jeweils generieren">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1730598456797" ID="ID_1189534095" MODIFIED="1730598466247" TEXT="aus den hinterlegten semantischen Infos"/>
<node CREATED="1730598456797" ID="ID_1189534095" MODIFIED="1730598466247" TEXT="aus den hinterlegten semantischen Infos">
<node COLOR="#338800" CREATED="1730685985639" ID="ID_1668280746" MODIFIED="1730686128081" TEXT="die Proc-Spec f&#xfc;r den Turnout">
<richcontent TYPE="NOTE"><html>
<head/>
<body>
<ul>
<li>
geplantes vollst&#228;ndiges Format:<br />&#160;<font face="Monospaced">NodeSymb[.portQualifier](inType[/#][,inType[/#]])(outType[/#][,outType[/#]][ &gt;N])</font>
</li>
</ul>
<ul>
<li>
tats&#228;chlich auf dieser Ebene implementiert<br /><font face="Monospaced">NodeSymb[.portQualifier]&lt;argumentList&gt;</font>
</li>
</ul>
</body>
</html>
</richcontent>
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1730598467124" ID="ID_1212008827" MODIFIED="1730598478595" TEXT="plus einer direkt hereingereichten Connectivity">
<icon BUILTIN="flag-yellow"/>
</node>