title: Progress Bar design patterns?
body: <p>The application I'm writing performs a length algorithm which usually takes a few minutes to finish. During this time I'd like to show the user a progress bar which indicates how much of the algorithm is done as precisely as possible.</p>
  
  <p>The algorithm is divided into several steps, each with its own typical timing. For instance-  </p>
  
  <ul>
  <li>initialization (500 milli-sec)</li>
  <li>reading inputs (5 sec)</li>
  <li>step 1 (30 sec)</li>
  <li>step 2 (3 minutes)</li>
  <li>writing outputs (7 sec)</li>
  <li>shutting down (10 milli-sec)</li>
  </ul>
  
  <p>Each step can report its progress quite easily by setting the range its working on, say [0 to 150] and then reporting the value it completed in its main loop.</p>
  
  <p>What I currently have set up is a scheme of nested progress monitors which form a sort of implicit tree of progress reporting.</p>
  
  <p>All progress monitors inherit from an interface <code>IProgressMonitor</code>:</p>
  
  <pre><code>class IProgressMonitor
  {
  public:
    void setRange(int from, int to) = 0;
    void setValue(int v) = 0;
  };
  </code></pre>
  
  <p>The root of the tree is the ProgressMonitor which is connected to the actual GUI interface:</p>
  
  <pre><code>class GUIBarProgressMonitor : public IProgressMonitor
  {
     GUIBarProgressMonitor(ProgressBarWidget *);
  };
  </code></pre>
  
  <p>Any other node in the tree are monitors which take control of a piece of the parent progress:</p>
  
  <pre><code>class SubProgressMonitor : public IProgressMonitor
  {
    SubProgressMonitor(IProgressMonitor *parent, int parentFrom, int parentLength)
    ...
  };
  </code></pre>
  
  <p>A <code>SubProgressMonitor</code> takes control of the range <code>[parentFrom, parentFrom+parentLength]</code> of its parent.</p>
  
  <p>With this scheme I am able to statically divide the top level progress according to the expected relative portion of each step in the global timing. Each step can then be further subdivided into pieces etc'</p>
  
  <p>The main disadvantage of this is that the division is static and it gets painful to make changes according to variables which are discovered at run time.</p>
  
  <p>So the question: are there any known design patterns for progress monitoring which solve this issue?</p>