Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UICoordResolver Class Reference

#include "gui/interact/ui-coord-resolver.hpp"

Description

Query and mutate UICoord specifications in relation to actual UI topology.

This specialised builder uses a location query facility to retrieve information about the current actual UI topology. The UI coordinate spec given as initialisation acts as a pattern, to be queried and resolved against that actual UI topology in various ways

  • determine the anchor point, where this UI coordinate pattern will be rooted in the UI
  • determine to which extent this UI coordinate pattern can be _"covered"_ (= supported) by the exiting UI. To resolve this query, it is necessary to perform a matching search with backtracking, in order to find the best possible coverage ** the coverage can be complete, which means that all components mentioned explicitly within the pattern in fact exist in the actual UI ** a partial coverage means that there is a prefix actually supported, while some extraneous tailing components do not (yet) exist in the UI. Moreover, the pattern can be mutated to conform with the existing UI topology:
  • the anchor point can be made explicit, which means to replace the meta specifications ** firstWindow ** currentWindow
  • the calculated coverage solution can be interpolated into the pattern, thereby binding and replacing any placeholders ("wildcards", i.e. components designated as "*")
  • we may extend the pattern by attaching further elements, behind the covered part.
    Note
    this is a coordinate builder, which means that it works on a copy of the UI coordinate pattern provided at initialisation. The result, a possibly reworked UI coordinate spec can be moved out into a new target UI coordinate (which is then immutable). The various query and binding operations work by side-effect on the internal state encapsulated within this builder.
    Warning
    computing a coverage solution for a sparsely defined pattern against a large UI topology can be expensive, since in worst case we have to perform a depth-first scan of the whole tree structure

Definition at line 279 of file ui-coord-resolver.hpp.

Public Member Functions

 UICoordResolver (UICoord const &uic, LocationQuery &queryAPI)
 
 UICoordResolver (UICoord &&uic, LocationQuery &queryAPI)
 
UICoordResolver && anchor ()
 mutate the window part of the path such as to make the anchorage explicit, if possible More...
 
bool canAnchor () const
 determine if a mutation is possible to anchor the path explicitly More...
 
bool canCover () const
 determine if a mutation is possible to get the path (partially) covered. More...
 
UICoordResolver && cover ()
 mutate the path to get it totally covered More...
 
size_t coverDepth () const
 
UICoordResolver && coverPartially ()
 mutate the path by resolving all wildcards to achieve partial coverage More...
 
UICoordResolver && existentiallyQuantify (size_t pos)
 mutate to turn a wildcard into existentially quantified. This means to assume (or require) that an element actually exists at the given position, without knowing or caring about its actual name. More...
 
UICoordResolver && extend (Literal pathExtension)
 mutate the path to extend it while keeping it partially covered More...
 
UICoordResolver && extend (UICoord const &partialExtensionSpec)
 mutate the path and extend it with components at fixed positions More...
 
bool isAnchored () const
 is this path explicitly anchored at an existing window? More...
 
bool isCovered () const
 this path is completely covered by the currently existing UI structure; More...
 
bool isCoveredPartially () const
 is this path at least partially covered? A covered path describes an access path through widgets actually existing in the UI. More...
 
bool isCoveredTotally () const
 synonymous to isCovered() More...
 
 operator string () const
 diagnostics More...
 
- Public Member Functions inherited from UICoord::Builder
 Builder (Builder &&)=default
 
Builder && append (Literal elm)
 augment UI coordinates by appending a further component at the end. More...
 
LocationClause create ()
 interprets the current (inline) builder contents as create clause, which has the meaning "create a new element XYZ when possible" More...
 
bool empty () const
 
Builder && noTab ()
 augment UI coordinates to indicate that no tab specification is necessary More...
 
 operator LocationClause ()
 support for use in the ViewSpec-DSL More...
 
Builder && panel (Literal panelID)
 augment UI coordinates to indicate a specific view to be used More...
 
Builder && path (Literal pathDef)
 augment UI coordinates to define a complete local path More...
 
Builder && persp (Literal perspectiveID)
 augment UI coordinates to mandate a specific perspective to be active within the window More...
 
Builder && prepend (Literal elmID)
 augment partially defined UI coordinates by extending them towards the root More...
 
size_t size () const
 
Builder && tab (Literal tabID)
 augment UI coordinates to indicate a specific tab within the view" More...
 
Builder && tab (uint tabIdx)
 augment UI coordinates to indicate a tab specified by index number More...
 
Builder && truncateTo (size_t depth)
 possibly shorten this path specification to a limited depth More...
 
Builder && view (Literal viewID)
 augment UI coordinates to indicate a specific view to be used More...
 
Builder && window (Literal windowID)
 change UI coordinate spec to define it to be rooted within the given window More...
 

Classes

struct  Resolution
 

Private Member Functions

void attempt_trivialResolution ()
 establish a trivial anchorage and coverage, if possible. More...
 
bool pathResolution ()
 Since UICoord path specifications may contain gaps and wildcards, we may attempt to fill in these missing parts by matching against the topological structure of an actual UI. More...
 

Private Attributes

LocationQueryquery_
 
Resolution res_
 

Additional Inherited Members

- Protected Member Functions inherited from UICoord::Builder
template<typename... ARGS>
 Builder (ARGS &&...args)
 
 Builder (UICoord &&anonRef)
 
 Builder (UICoord const &base)
 
Builder && normalise ()
 
Builder && overwrite (size_t depth, Literal newSpec)
 
- Protected Attributes inherited from UICoord::Builder
UICoord uic_
 

Class Documentation

struct gui::interact::UICoordResolver::Resolution
Class Members
const char * anchor
size_t depth
unique_ptr< UICoord > covfefe
bool isResolved
+ Collaboration diagram for UICoordResolver::Resolution:

Constructor & Destructor Documentation

UICoordResolver ( UICoord const &  uic,
LocationQuery queryAPI 
)
inline

Definition at line 295 of file ui-coord-resolver.hpp.

UICoordResolver ( UICoord &&  uic,
LocationQuery queryAPI 
)
inline

Definition at line 303 of file ui-coord-resolver.hpp.

Member Function Documentation

bool isAnchored ( ) const
inline

is this path explicitly anchored at an existing window?

Remarks
this also implies the path is complete and explicit (no wildcards).

Definition at line 318 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::anchor, and Symbol::BOTTOM.

Referenced by UICoordResolver::canAnchor(), and UICoordResolver::pathResolution().

+ Here is the caller graph for this function:

bool canAnchor ( ) const
inline

determine if a mutation is possible to anchor the path explicitly

Remarks
basically this either means the path isAnchored(), or we're able to calculate a path resolution, interpolating any wildcards. And while the path resolution as such might fail, it was at least successful to determine an anchor point. The existence of such an anchor point implies the path is not totally in contradiction to the existing UI

Definition at line 332 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::covfefe, UICoordResolver::isAnchored(), UICoordResolver::Resolution::isResolved, and util::unConst().

Referenced by UICoordResolver::anchor().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool isCoveredPartially ( ) const
inline

is this path at least partially covered? A covered path describes an access path through widgets actually existing in the UI.

Remarks
this also implies the path is anchored, complete and explicit.
Note
this predicate tests for partial coverage, which means, there might be some extraneous suffix in this path descending beyond existing UI

Definition at line 347 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::depth, and UICoordResolver::Resolution::isResolved.

Referenced by UICoordResolver::cover(), and UICoordResolver::coverPartially().

+ Here is the caller graph for this function:

bool isCovered ( ) const
inline

this path is completely covered by the currently existing UI structure;

Remarks
there is no extraneous uncovered suffix in this path spec; moreover, the path is anchored, complete and explicit

Definition at line 358 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::depth, UICoordResolver::Resolution::isResolved, and UICoord::Builder::uic_.

Referenced by UICoordResolver::canCover(), UICoordResolver::cover(), UICoordResolver::extend(), and UICoordResolver::isCoveredTotally().

+ Here is the caller graph for this function:

bool isCoveredTotally ( ) const
inline

synonymous to isCovered()

Definition at line 366 of file ui-coord-resolver.hpp.

References UICoordResolver::isCovered().

+ Here is the call graph for this function:

bool canCover ( ) const
inline

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 explicitly stated component in the path can be confirmed (covered) by the existing UI. The idea behind this definition is that we do not want just some interpolated wildcards, rather we really want to confirm the essence of the path specification. Yet we accept an extraneous suffix in the explicitly given part of the path spec to extend beyond or below what exists currently within the UI.

Definition at line 382 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::covfefe, UICoordResolver::isCovered(), UICoordResolver::Resolution::isResolved, and util::unConst().

Referenced by UICoordResolver::cover(), UICoordResolver::coverPartially(), and UICoordResolver::extend().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UICoordResolver&& cover ( )
inline

mutate the path to get it totally covered

  • make the anchorage explicit
  • possibly match and expand any wildcards
  • then truncate the UI-Coordinate spec to that part actually covered by the UI
    Note
    if the coordinate spec can not be covered at all, it will be truncated to zero size

Definition at line 403 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::anchor, UICoordResolver::canCover(), UICoordResolver::Resolution::covfefe, UICoordResolver::Resolution::depth, ENSURE(), UICoordResolver::isCovered(), UICoordResolver::isCoveredPartially(), UICoordResolver::Resolution::isResolved, UICoord::Builder::truncateTo(), UICoord::Builder::uic_, and UICoord::Builder::window().

Referenced by UICoordResolver::extend().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UICoordResolver&& coverPartially ( )
inline

mutate the path by resolving all wildcards to achieve partial coverage

  • anchorage and all wildcards will be resolved against current UI
  • but an extraneous, uncovered, explicit suffix is retained
    Note
    if the coordinate spec can not be (partially) covered at all, it will be truncated to zero size

Definition at line 438 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::anchor, UICoordResolver::canCover(), UICoordResolver::Resolution::covfefe, UICoordResolver::Resolution::depth, UICoord::Builder::empty(), ENSURE(), UICoordResolver::isCoveredPartially(), UICoord::isExplicit(), UICoordResolver::Resolution::isResolved, UICoord::Builder::overwrite(), UICoord::Builder::truncateTo(), UICoord::Builder::uic_, and UICoord::Builder::window().

+ Here is the call graph for this function:

UICoordResolver&& anchor ( )
inline

mutate the window part of the path such as to make the anchorage explicit, if possible

Remarks
if the path starts with meta specs like firstWindow or currentWindow, they will be replaced by their current meaning. If the path is incomplete, but can somehow be resolved, we use the anchorage as indicated by that resolution, without interpolating the rest of the path.

Definition at line 478 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::anchor, UICoordResolver::canAnchor(), UICoord::Builder::normalise(), and UICoord::Builder::window().

+ Here is the call graph for this function:

UICoordResolver&& extend ( Literal  pathExtension)
inline

mutate the path to extend it while keeping it partially covered

Parameters
pathExtensiona literal specification, which is extended immediately behind the actually covered part of the path, irrespective of the depth
Note
the extension may contain '/', which are treated as component separators

Definition at line 496 of file ui-coord-resolver.hpp.

References UICoord::Builder::append(), UICoordResolver::cover(), UICoordResolver::Resolution::depth, LocationQuery::determineCoverage(), ENSURE(), UICoordResolver::isCovered(), and UICoord::Builder::uic_.

+ Here is the call graph for this function:

UICoordResolver&& extend ( UICoord const &  partialExtensionSpec)
inline

mutate the path and extend it with components at fixed positions

Parameters
partialExtensionSpecUI coordinates used as extension
Exceptions
ifthe extension would overwrite the covered part.
Remarks
this is the typical use case, where we want to place some component explicitly at a given depth (e.g. a new view or tab)

Definition at line 513 of file ui-coord-resolver.hpp.

References UICoordResolver::attempt_trivialResolution(), UICoordResolver::canCover(), UICoordResolver::cover(), UICoordResolver::Resolution::covfefe, UICoordResolver::Resolution::depth, UICoordResolver::Resolution::isResolved, UICoord::Builder::normalise(), UICoord::Builder::overwrite(), UICoord::rebuild(), UICoord::Builder::truncateTo(), and UICoord::Builder::uic_.

+ Here is the call graph for this function:

UICoordResolver&& existentiallyQuantify ( size_t  pos)
inline

mutate to turn a wildcard into existentially quantified. This means to assume (or require) that an element actually exists at the given position, without knowing or caring about its actual name.

This becomes relevant when matching for partially covered path; normal wildcards are only accepted to build a solution, when the matching can be confirmed by an explicit element after (below) the wildcard part. While this restriction serves to prevent ambiguous and surprising arbitrary matches, it can sometimes defeat any solution, e.g. when creating a new panel on top of an existing but irrelevant perspective.

Definition at line 552 of file ui-coord-resolver.hpp.

References UICoord::isPresent(), UICoord::Builder::overwrite(), UICoord::Builder::uic_, and gui::interact::UIC_ELIDED.

+ Here is the call graph for this function:

operator string ( ) const
inline

diagnostics

Definition at line 562 of file ui-coord-resolver.hpp.

References UICoord::Builder::uic_.

size_t coverDepth ( ) const
inline

Definition at line 563 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::depth.

void attempt_trivialResolution ( )
inlineprivate

establish a trivial anchorage and coverage, if possible.

Note
when the UICoord contains wildcards or is incomplete, a full resolution with backtracking is necessary to determine anchorage and coverage. The same is true when the pattern uses an elided element, since such an existentially quantified item must be interpolated.

Definition at line 576 of file ui-coord-resolver.hpp.

References UICoordResolver::Resolution::anchor, util::contains(), UICoordResolver::Resolution::depth, LocationQuery::determineAnchor(), LocationQuery::determineCoverage(), UICoord::isExplicit(), UICoordResolver::Resolution::isResolved, UICoord::Builder::uic_, and gui::interact::UIC_ELIDED.

Referenced by UICoordResolver::extend().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool pathResolution ( )
private

Since UICoord path specifications may contain gaps and wildcards, we may attempt to fill in these missing parts by matching against the topological structure of an actual UI.

algorithm to resolve this UICoord path against the actual UI topology.

Returns
true if total coverage is possible (by interpolating wildcards)
Remarks
after invoking this function, res_.isResolved and possible coverage are set.

In the general case, finding a solution requires a depth-first exponential brute-force search over the whole structure tree, since we have to try every possible branch until we can disprove the possibility of a match. Implemented as depth-first search with backtracking, this scanning pass produces a list of possible matches, from which we pick the first one with maximum coverage, to yield a single solution.

Remarks
the search and matching is based on an iterator pipeline builder, with the special ability to expand and recurse into the children of the current element on demand: when expandChildren() was invoked, the next iteration will continue with the first child element; there is a stack of such "child expansions" – meaning that the search will backtrack and explore further possibilities later on. Each position where the pattern matches the actual tree is marked as possible solution. As a sideeffect, a new coordinate spec to reflect the actual coverage is built and re-written, while the algorithm proceeds. Thus, at any point marked as solution, the current (partial) solution can be retrieved and copied from this PathManipulator buffer. An additional filter layer discriminates the first maximal solutions seen thus far.

Definition at line 125 of file ui-coord-resolver.cpp.

References UICoordResolver::Resolution::anchor, Symbol::ANY, UICoordResolver::Resolution::covfefe, curr, UICoordResolver::Resolution::depth, LocationQuery::determineCoverage(), Symbol::EMPTY, ENSURE(), LocationQuery::getChildren(), UICoordResolver::isAnchored(), util::isnil(), UICoordResolver::Resolution::isResolved, UICoordResolver::query_, UICoordResolver::res_, lib::iter_source::transform(), UICoord::Builder::uic_, gui::interact::UIC_ELIDED, and gui::interact::UIC_WINDOW.

+ Here is the call graph for this function:

Member Data Documentation

LocationQuery& query_
private

Definition at line 291 of file ui-coord-resolver.hpp.

Referenced by UICoordResolver::pathResolution().

Resolution res_
private

Definition at line 292 of file ui-coord-resolver.hpp.

Referenced by UICoordResolver::pathResolution().

+ Inheritance diagram for UICoordResolver:
+ Collaboration diagram for UICoordResolver:

The documentation for this class was generated from the following files: