EventLog: consolidate existing calls to configure the search

create a narrow configuration API for the underlying search mechanism.
Simplifies the task of turning that search into a real backtracking evaluation.
This commit is contained in:
Fischlurch 2018-09-03 02:27:32 +02:00
parent 604ffbf73c
commit b3f328f28d
2 changed files with 58 additions and 31 deletions

View file

@ -308,6 +308,37 @@ namespace test{
}
/* === configure the underlying search engine === */
enum Direction {
FORWARD, BACKWARD
};
template<typename COND>
void
attachNextSerchStep (COND&& filter, Direction direction)
{
switch (direction)
{
case FORWARD:
solution_.underlying().switchForwards();
break;
case BACKWARD:
solution_.underlying().switchBackwards();
break;
}
solution_.setNewFilter (forward<COND> (filter));
}
template<typename COND>
void
refineSerach (COND&& additionalFilter)
{
solution_.andFilter (forward<COND> (additionalFilter));
}
public:
/** final evaluation of the match query,
* usually triggered from the unit test `CHECK()`.
@ -335,8 +366,7 @@ namespace test{
EventMatch&
before (string match)
{
solution_.underlying().switchForwards();
solution_.setNewFilter(find(match));
attachNextSerchStep (find(match), FORWARD);
evaluateQuery ("match(\""+match+"\")");
return *this;
}
@ -345,8 +375,7 @@ namespace test{
EventMatch&
beforeMatch (string regExp)
{
solution_.underlying().switchForwards();
solution_.setNewFilter(findRegExp(regExp));
attachNextSerchStep (findRegExp(regExp), FORWARD);
evaluateQuery ("find-RegExp(\""+regExp+"\")");
return *this;
}
@ -367,8 +396,7 @@ namespace test{
EventMatch&
beforeEvent (string match)
{
solution_.underlying().switchForwards();
solution_.setNewFilter(findEvent(match));
attachNextSerchStep (findEvent(match), FORWARD);
evaluateQuery ("match-event(\""+match+"\")");
return *this;
}
@ -376,8 +404,7 @@ namespace test{
EventMatch&
beforeEvent (string classifier, string match)
{
solution_.underlying().switchForwards();
solution_.setNewFilter(findEvent(classifier,match));
attachNextSerchStep (findEvent(classifier,match), FORWARD);
evaluateQuery ("match-event(ID=\""+classifier+"\", \""+match+"\")");
return *this;
}
@ -389,8 +416,7 @@ namespace test{
EventMatch&
beforeCall (string match)
{
solution_.underlying().switchForwards();
solution_.setNewFilter(findCall(match));
attachNextSerchStep (findCall(match), FORWARD);
evaluateQuery ("match-call(\""+match+"\")");
return *this;
}
@ -398,8 +424,7 @@ namespace test{
EventMatch&
after (string match)
{
solution_.underlying().switchBackwards();
solution_.setNewFilter(find(match));
attachNextSerchStep (find(match), BACKWARD);
evaluateQuery ("match(\""+match+"\")", "before");
return *this;
}
@ -407,8 +432,7 @@ namespace test{
EventMatch&
afterMatch (string regExp)
{
solution_.underlying().switchBackwards();
solution_.setNewFilter(findRegExp(regExp));
attachNextSerchStep (findRegExp(regExp), BACKWARD);
evaluateQuery ("find-RegExp(\""+regExp+"\")", "before");
return *this;
}
@ -416,8 +440,7 @@ namespace test{
EventMatch&
afterEvent (string match)
{
solution_.underlying().switchBackwards();
solution_.setNewFilter(findEvent(match));
attachNextSerchStep (findEvent(match), BACKWARD);
evaluateQuery ("match-event(\""+match+"\")", "before");
return *this;
}
@ -425,8 +448,7 @@ namespace test{
EventMatch&
afterEvent (string classifier, string match)
{
solution_.underlying().switchBackwards();
solution_.setNewFilter(findEvent(classifier,match));
attachNextSerchStep (findEvent(classifier,match), BACKWARD);
evaluateQuery ("match-event(ID=\""+classifier+"\", \""+match+"\")", "before");
return *this;
}
@ -435,8 +457,7 @@ namespace test{
EventMatch&
afterCall (string match)
{
solution_.underlying().switchBackwards();
solution_.setNewFilter(findCall(match));
attachNextSerchStep (findCall(match), BACKWARD);
evaluateQuery ("match-call(\""+match+"\")", "before");
return *this;
}
@ -454,7 +475,7 @@ namespace test{
ArgSeq argSeq(stringify<ArgSeq> (args...));
string argList(util::join(argSeq));
solution_.andFilter (matchArguments(move(argSeq)));
refineSerach (matchArguments(move(argSeq)));
evaluateQuery ("match-arguments("+argList+")");
return *this;
}
@ -473,7 +494,7 @@ namespace test{
EventMatch&
argMatch (ARGS const& ...regExps)
{
solution_.andFilter (matchArgsRegExp (stringify<RExSeq> (regExps...)));
refineSerach (matchArgsRegExp (stringify<RExSeq> (regExps...)));
evaluateQuery ("match-args-RegExp("+util::join(stringify<ArgSeq>(regExps...))+")");
return *this;
}
@ -482,7 +503,7 @@ namespace test{
EventMatch&
type (string typeID)
{
solution_.andFilter (matchType(typeID));
refineSerach (matchType(typeID));
evaluateQuery ("match-type("+typeID+")");
return *this;
}
@ -491,7 +512,7 @@ namespace test{
EventMatch&
key (string key)
{
solution_.andFilter (ensureAttribute(key));
refineSerach (ensureAttribute(key));
evaluateQuery ("ensure-attribute("+key+")");
return *this;
}
@ -500,7 +521,7 @@ namespace test{
EventMatch&
attrib (string key, string valueMatch)
{
solution_.andFilter (matchAttribute(key,valueMatch));
refineSerach (matchAttribute(key,valueMatch));
evaluateQuery ("match-attribute("+key+"=\""+valueMatch+"\")");
return *this;
}
@ -509,7 +530,7 @@ namespace test{
EventMatch&
id (string classifier)
{
solution_.andFilter (matchAttribute("ID",classifier));
refineSerach (matchAttribute("ID",classifier));
evaluateQuery ("match-ID(\""+classifier+"\")");
return *this;
}
@ -518,7 +539,7 @@ namespace test{
EventMatch&
on (string targetID)
{
solution_.andFilter (matchAttribute("this",targetID));
refineSerach (matchAttribute("this",targetID));
evaluateQuery ("match-this(\""+targetID+"\")");
return *this;
}
@ -526,7 +547,7 @@ namespace test{
EventMatch&
on (const char* targetID)
{
solution_.andFilter (matchAttribute("this",targetID));
refineSerach (matchAttribute("this",targetID));
evaluateQuery ("match-this(\""+string(targetID)+"\")");
return *this;
}
@ -536,7 +557,7 @@ namespace test{
on (const X *const targetObj)
{
string targetID = idi::instanceTypeID (targetObj);
solution_.andFilter (matchAttribute("this",targetID));
refineSerach (matchAttribute("this",targetID));
evaluateQuery ("match-this(\""+targetID+"\")");
return *this;
}

View file

@ -30840,7 +30840,7 @@
<icon BUILTIN="help"/>
</node>
</node>
<node COLOR="#338800" CREATED="1535893707036" ID="ID_257876647" MODIFIED="1535932142834" TEXT="Aufgabe: Filter erweiterbar machen">
<node COLOR="#338800" CREATED="1535893707036" FOLDED="true" ID="ID_257876647" MODIFIED="1535934249016" TEXT="Aufgabe: Filter erweiterbar machen">
<icon BUILTIN="button_ok"/>
<node CREATED="1535893718194" ID="ID_872370459" MODIFIED="1535893743691" TEXT="analog zum Filter in den Itertools"/>
<node CREATED="1535893752174" ID="ID_386073545" MODIFIED="1535893777011" TEXT="ggfs diesen dort abl&#xf6;sen">
@ -31131,7 +31131,9 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1535899922873" ID="ID_1971708144" MODIFIED="1535899950863" TEXT="bestehende Aufrufe konsolidieren">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1535899922873" ID="ID_1971708144" MODIFIED="1535934181826" TEXT="bestehende Aufrufe in EventMatch konsolidieren">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1535934086931" ID="ID_805705448" MODIFIED="1535934155059" TEXT="internes API f&#xfc;r die Such-Konfiguration einf&#xfc;hren">
<richcontent TYPE="NOTE"><html>
<head>
@ -31143,9 +31145,13 @@
</body>
</html>
</richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1535934121614" ID="ID_757923717" MODIFIED="1535934185871" TEXT="umstellen von IterTools -&gt; TreeExplorer">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
</node>
<node CREATED="1535893799799" ID="ID_706866636" MODIFIED="1535893804419" TEXT="Auswertungs-Stack">
<node CREATED="1535893826972" ID="ID_352546105" MODIFIED="1535894073967" TEXT="aktueller Frame">
<node CREATED="1535894074891" ID="ID_1972842519" MODIFIED="1535923151832" TEXT="== aktuell wirksamer Suchfilter"/>