LOOS  v2.3.2
ProgressTriggers.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2009, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #if !defined(LOOS_PROGRESSTRIGGERS_HPP)
23 #define LOOS_PROGRESSTRIGGERS_HPP
24 
25 #include <loos_defs.hpp>
26 #include <ProgressCounters.hpp>
27 
28 
29 namespace loos {
30 
32  class TriggerEvery {
33  public:
34  TriggerEvery(const uint i) : freq(i) { }
35  bool operator()(SimpleCounter*);
36  void setFrequency(const uint);
37 
38  private:
39  uint freq;
40  };
41 
42 
44 
50  public:
51  PercentTrigger(double frac) : frac_(frac), chunk_(0) { }
52  void setFraction(double);
53  void reset(void);
54 
55  bool operator()(SimpleCounter*);
56 
57  private:
58  double frac_;
59  int chunk_;
60  };
61 
62 
63 }
64 
65 
66 #endif
Trigger every i-iterations.
Basic progress counter object, defining the interface...
Namespace for most things not already encapsulated within a class.
Trigger whenever at least frac percent more iterations have happened.