UXProgressChild
UXProgressChild attaches a sub-UXProgress
to a parent, with a share of the parent’s total units.
#use <UXKit> // or #import "UXProgress.xc"Overview
Section titled “Overview”class UXProgressChild : Object { UXProgress* prog; // the sub-task i32 units; // how many of the PARENT's units it stands for}Units are the parent’s, not the child’s
Section titled “Units are the parent’s, not the child’s”parent total 100 child A allocated 70 units (internally: 3500 files) child B allocated 30 units (internally: 12 steps)The child counts in whatever units suit it (files, bytes, steps), and the parent does not know them. The parent records how much of its own total that child is worth.
A child that is half done contributes half of its allocated units. Child A at 50% adds 35 to the parent, whatever 50% meant inside it.
This lets a long operation report coarse progress and hand slices to sub-tasks that report their own, without any of them agreeing on a unit.
Allocation is a promise the parent makes
Section titled “Allocation is a promise the parent makes”Nothing checks that the children’s units add up to the parent’s total. Two
things follow:
- Allocate less than the total and the remainder is the parent’s own work,
tracked by its
completedcount. This is the normal case: “I do 20 units myself and delegate 80.” - Allocate more and the arithmetic overshoots.
fractionMilleclamps to 1000, so a bar driven by it stops at full rather than running past its end. It reaches full early and stays there, a visible symptom rather than a drawing fault.
Keeping the sum correct is the caller’s job. In exchange, the parent does not re-plan every time a child appears.
Fractions are per mille
Section titled “Fractions are per mille”The roll-up reports 0–1000 rather than a percentage or a float, so that a
child at one-third contributes exactly, in integers, at every level of the tree.
Percent would lose a third of a percent per level. A float would give a different
answer on a backend with a different FPU. See
UXProgress for the arithmetic.
The child is held strongly
Section titled “The child is held strongly”UXProgress* progA parent owns its children. A sub-task whose progress object had been collected would silently stop contributing.
The child does not point back. A progress tree therefore has no cycle to break, and a sub-task cannot ask what fraction of the whole it represents. Only the parent knows that.
Fields
Section titled “Fields”UXProgress* progi32 unitsThe parent’s units this child stands for.
Conforms to
Section titled “Conforms to”- Inherits
Object
See also
Section titled “See also”UXProgress: the node, and the roll-upUXProgressBar: showing the result