Navigator: implement the mutation operations defined thus far

...so the only thing not yet implemented is the actual path resolution algorithm
This commit is contained in:
Fischlurch 2017-10-30 03:10:51 +01:00
parent e035dbc54a
commit ca35891c41
2 changed files with 52 additions and 18 deletions

View file

@ -50,7 +50,7 @@
#include "gui/interact/ui-coord.hpp"
#include "lib/iter-source.hpp"
#include "lib/iter-stack.hpp"
//#include "lib/util.hpp"
#include "lib/util.hpp"
//#include <boost/noncopyable.hpp>
//#include <string>
@ -68,7 +68,7 @@ namespace interact {
// using std::string;
using lib::Literal;
// using lib::Symbol;
// using util::unConst;
using util::unConst;
// using util::isnil;
// using util::min;
@ -198,7 +198,7 @@ namespace interact {
{
return isAnchored()
or (res_.isResolved and res_.covfefe)
or pathResolution()
or unConst(this)->pathResolution()
or isAnchored(); // resolution failed, but computed at least an anchor
}
@ -215,6 +215,14 @@ namespace interact {
and res_.depth > 0;
}
/** there is no extraneous uncovered suffix in this path spec */
bool
isTotallyCovered() const
{
return res_.isResolved
and res_.depth == this->uic_.size();
}
/** 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
@ -229,29 +237,51 @@ namespace interact {
{
return isCovered()
or (res_.isResolved and res_.covfefe)
or pathResolution();
or unConst(this)->pathResolution();
}
/* === mutation functions === */
/**
/** mutate the path to get it totally covered
*/
UICoordResolver
cover()
{
UNIMPLEMENTED ("mutate the path to get it covered");
if (isCovered())
truncateTo (res_.depth);
else if (canCover())
{
ASSERT (res_.isResolved);
REQUIRE (res_.covfefe);
res_.depth = res_.covfefe->size();
std::swap (this->uic_, *res_.covfefe);
res_.covfefe.reset();
ENSURE (isTotallyCovered());
}
else
{
ASSERT (res_.isResolved);
REQUIRE (res_.depth == 0);
REQUIRE (not res_.covfefe);
truncateTo (0);
}
return std::move (*this);
}
/**
/** mutate the path to extend it while keeping it partially covered
*/
UICoordResolver
extend (Literal pathExtension)
{
UNIMPLEMENTED ("mutate the path to extend it while keeping it partially covered");
if (not isTotallyCovered())
cover();
ENSURE (isTotallyCovered());
append (pathExtension);
res_.depth = query_.determineCoverage (this->uic_); // coverage may grow
ENSURE (isCovered());
return std::move (*this);
}

View file

@ -4254,8 +4254,9 @@
</richcontent>
<icon BUILTIN="help"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508537057661" ID="ID_1582824657" MODIFIED="1508537073664" TEXT="was hei&#xdf;t &quot;covern&quot;?">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1508537057661" ID="ID_1582824657" MODIFIED="1509329323916" TEXT="was hei&#xdf;t &quot;covern&quot;?">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="button_ok"/>
<node CREATED="1508538092061" ID="ID_731131821" MODIFIED="1508538096663" TEXT="komplett/partiell?"/>
<node CREATED="1508538108338" ID="ID_1403158284" MODIFIED="1508625730742" TEXT="so gut wie m&#xf6;glich">
<icon BUILTIN="forward"/>
@ -4542,9 +4543,11 @@
<node CREATED="1508540764667" ID="ID_772420189" MODIFIED="1508540772133" TEXT="scheitert: Anchor == bottom"/>
<node CREATED="1508540811196" ID="ID_841748634" MODIFIED="1508540819447" TEXT="Ergebnis: Window-Komponente setzen"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539195258" ID="ID_1044429952" MODIFIED="1508539197986" TEXT="cover">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1508540823475" ID="ID_793410656" MODIFIED="1508540829869" TEXT="path-resolution ausf&#xfc;hren"/>
<node COLOR="#338800" CREATED="1508539195258" ID="ID_1044429952" MODIFIED="1509329355200" TEXT="cover">
<icon BUILTIN="button_ok"/>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1508540823475" ID="ID_793410656" MODIFIED="1509329351169" TEXT="path-resolution ausf&#xfc;hren">
<icon BUILTIN="flag-pink"/>
</node>
<node CREATED="1508540835505" ID="ID_191493714" MODIFIED="1508540848899" TEXT="swap(*this, Coverage)"/>
</node>
</node>
@ -4666,11 +4669,12 @@
<icon BUILTIN="button_ok"/>
</node>
</node>
<node CREATED="1506984614487" ID="ID_380908645" MODIFIED="1506984616051" TEXT="UICoordResolver_test">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645745" ID="ID_244163155" MODIFIED="1506984665826" TEXT="verify_simpleUsage">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1506984614487" ID="ID_380908645" MODIFIED="1509329414242" TEXT="UICoordResolver_test">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645745" ID="ID_244163155" MODIFIED="1509329383990" TEXT="verify_simpleUsage">
<icon BUILTIN="pencil"/>
</node>
<node COLOR="#338800" CREATED="1506984645747" ID="ID_517262443" MODIFIED="1509288984297" TEXT="verify_backingQuery">
<node COLOR="#338800" CREATED="1506984645747" FOLDED="true" ID="ID_517262443" MODIFIED="1509329403961" TEXT="verify_backingQuery">
<icon BUILTIN="button_ok"/>
<node CREATED="1508809610790" FOLDED="true" ID="ID_1860790851" MODIFIED="1509145537374" TEXT="Builder-Syntax war falsch">
<icon BUILTIN="button_ok"/>
@ -4712,7 +4716,7 @@
<icon BUILTIN="ksmiletris"/>
</node>
</node>
<node CREATED="1509142651113" FOLDED="true" ID="ID_99734013" MODIFIED="1509319931404">
<node CREATED="1509142651113" FOLDED="true" ID="ID_99734013" MODIFIED="1509329402043">
<richcontent TYPE="NODE"><html>
<head>