LocationSolver: draft the success cases for a location solution

This commit is contained in:
Fischlurch 2018-02-09 04:10:53 +01:00
parent 66bbf146a6
commit f8dd3a7030
3 changed files with 53 additions and 27 deletions

View file

@ -361,6 +361,14 @@ namespace interact {
and res_.depth == this->uic_.size();
}
/** synonymous to #isCovered() */
bool
isCoveredTotally() const
{
return isCovered();
}
/** determine if a mutation is possible to get the path (partially) covered.
* @remarks in order to be successful, a path resolution must interpolate any gaps in the
* path spec _and_ reach a point behind / below the gap (wildcards), where an existing

View file

@ -71,32 +71,21 @@ namespace interact {
class LocationClause
struct LocationClause
: boost::noncopyable
{
UICoord pattern_;
bool createParents_;
UICoord pattern;
bool createParents;
public:
LocationClause (UICoord && locationPattern, bool createParents =false)
: pattern_{move (locationPattern)}
, createParents_{createParents}
LocationClause (UICoord && locationPattern, bool allowCreate =false)
: pattern{move (locationPattern)}
, createParents{allowCreate}
{ }
LocationClause (LocationClause && rr)
: pattern_{move (rr.pattern_)}
, createParents_{rr.createParents_}
: pattern{move (rr.pattern)}
, createParents{rr.createParents}
{ }
operator UICoord const&() const
{
return pattern_;
}
size_t
size() const
{
return pattern_.size();
}
};
@ -182,7 +171,7 @@ namespace interact {
* Solve for a location according to the given location rule.
* @param depth desired kind of UI element (and thus the depth in the UI topology tree)
* @param elementType designator of the specific element to be created at that level
* @return a explicit location, resolved against the current UI topology. May be empty
* @return an explicit location, resolved against the current UI topology. May be empty
* @remarks the returned path is either empty (no solution exists), or it is "partially covered"
* by the existing UI; here, the "covered" part are the already existing UI elements,
* while the remaining, uncovered extension describes additional elements to be created.
@ -196,12 +185,26 @@ namespace interact {
{
for (auto& clause : rule)
{
if (clause.size() > depth+1) continue;
UICoordResolver resolver{clause, getLocationQuery()};
if (clause.pattern.size() > depth+1) continue;
UICoordResolver resolver{clause.pattern, getLocationQuery()};
resolver.coverPartially();
if (not isnil (resolver))
return move (resolver);
//////////////////////////////TODO this is only the more relaxed "create" case
if (clause.createParents)
{
if (not isnil (resolver))
//////////////////////////////////////TODO ensure correct depth. Possibly append element itself
return move (resolver);
else
if (clause.pattern.isExplicit())
// allow creation of a totally new path
// as long as it is complete and explicitly given
return clause.pattern;
}
else
{
if (not isnil (resolver) and resolver.isCoveredTotally())
//////////////////////////////////////TODO ensure correct depth. Possibly append element itself
return move (resolver);
}
}
}

View file

@ -9960,6 +9960,9 @@
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518055394000" ID="ID_1230502265" MODIFIED="1518055399228" TEXT="alles bis auf Komponente selber">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1518143878531" ID="ID_780612574" MODIFIED="1518143891082" TEXT="d.h. mu&#xdf; total covered sein">
<icon BUILTIN="idea"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518055400412" ID="ID_1517580371" MODIFIED="1518055426432">
<richcontent TYPE="NODE"><html>
@ -9981,7 +9984,7 @@
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518055442607" ID="ID_93235547" MODIFIED="1518055447159" TEXT="partielle coverage erlauben">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518055453981" ID="ID_1927049673" MODIFIED="1518055539515" TEXT="Frage: totale Neuerzeugung unterst&#xfc;tzen?">
<node COLOR="#338800" CREATED="1518055453981" ID="ID_1927049673" MODIFIED="1518145561724" TEXT="Frage: totale Neuerzeugung unterst&#xfc;tzen?">
<richcontent TYPE="NOTE"><html>
<head>
@ -9997,9 +10000,21 @@
</html>
</richcontent>
<icon BUILTIN="help"/>
<node CREATED="1518145517036" ID="ID_272248384" MODIFIED="1518145520391" TEXT="ja">
<icon BUILTIN="yes"/>
</node>
<node COLOR="#338800" CREATED="1518145521684" ID="ID_17194778" MODIFIED="1518145547345" TEXT="ungedeckter Pfad mu&#xdf; explizit sein">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518145595274" ID="ID_1539200142" MODIFIED="1518145607193" TEXT="in jedem Fall korrekte L&#xe4;nge sicherstellen">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1518145778249" ID="ID_462394658" MODIFIED="1518145795919" TEXT="F&#xe4;lle geschickt zusammenfassen (duplikate Aktionen)">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1517507082826" ID="ID_1177191870" MODIFIED="1517507092970" TEXT="R&#xfc;ckgabe per Value">
<icon BUILTIN="flag-yellow"/>
</node>