OpenCurves
0.9
|
Contains utility functions for binding expression tree branches. More...
Functions | |
BindResult | bindMultiple (const QList< PlotInstance * > &curves, PlotBindingTracker &bindTracker, BindInfo &head, BindInfo *tail, unsigned tailLength, bool repeatLast) |
Bind multiple expressions, ensuring exhaustive binding combinations. More... | |
Contains utility functions for binding expression tree branches.
Tree based PlotExpression
objects may require binding on multiple branches. Each branch may in turn require binding multiple times. For example, consider the following expression:
This creates the following expression tree:
Both PlotSample
nodes are using regular expressions. Now, if the available curves are: [ 'speed_measured', 'speed_reported' ], then the resulting bindings should result in a comparison of 'speed_measured' against 'speed_reported'. The bindMultiple()
functions handle this sort of exhaustive binding, resulting in four bindings in this case:
While this is excessive, it ensures all required bindings are made.
The bindMultiple()
functions should be used by any PlotExpression
which has two or more child expressions. For such an expresison, the bind()
method should look somewhat as follows:
This is a binary binding. A ternary binding would have additional elements in bindings
.
BindResult binding::bindMultiple | ( | const QList< PlotInstance * > & | curves, |
PlotBindingTracker & | bindTracker, | ||
BindInfo & | head, | ||
BindInfo * | tail, | ||
unsigned | tailLength, | ||
bool | repeatLast | ||
) |
Bind multiple expressions, ensuring exhaustive binding combinations.
This binds the expression at head
, then recurses to bind the remaining items in tail
. The overall bind result is a combination of the head and tail results as follows:
Head Result | Tail Result | Final Result |
---|---|---|
Any | BindError | BindError |
Any | BindFailure | BindFailure |
BindError | Any | BindError |
BindFailure | Any | BindFailure |
Bound | Bound | Bound |
Bound | BoundMaybeMore | BoundMaybeMore |
BoundMaybeMore | Bound | BoundMaybeMore |
BoundMaybeMore | BoundMaybeMore | BoundMaybeMore |
curves | The curves available for binding. |
bindTracker | Tracks bind state for later bindings. |
head | The head of the list of items to bind. |
tail | A list of remaining expression requiring binding. |
tailLength | Number of elements in tail . |
repeatLast | True to remake the last binding if possible (as defined in bindTracker ). |