ardour
progress.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include <cassert>
21 #include <iostream>
22 #include "ardour/progress.h"
23 
24 using namespace std;
25 
27  : _cancelled (false)
28 {
29  descend (1);
30 }
31 
40 void
42 {
43  _stack.push_back (Level (a));
44 }
45 
46 void
48 {
49  assert (!_stack.empty ());
50  float const a = _stack.back().allocation;
51  _stack.pop_back ();
52  _stack.back().normalised += a;
53 }
54 
58 void
60 {
61  assert (!_stack.empty ());
62 
63  _stack.back().normalised = p;
64 
65  float overall = 0;
66  float factor = 1;
67  for (list<Level>::iterator i = _stack.begin(); i != _stack.end(); ++i) {
68  factor *= i->allocation;
69  overall += i->normalised * factor;
70  }
71 
72  set_overall_progress (overall);
73 }
74 
75 void
77 {
78  _cancelled = true;
79 }
80 
81 bool
83 {
84  return _cancelled;
85 }
Definition: Beats.hpp:239
void set_progress(float)
Definition: progress.cc:59
bool cancelled() const
Definition: progress.cc:82
void descend(float)
Definition: progress.cc:41