OpenMining  0.01
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
update_progress.h
Go to the documentation of this file.
1 #ifndef update_progress_h
2 #define update_progress_h
3 
4 #include <iostream>
5 
6 
7 namespace utils
8 {
9  template<class Tnewval, class Toldval>
10  bool update_progress(Tnewval& newval, Toldval& oldval)
11  {
12  bool retval = false;
13  if (oldval != newval)
14  {
15  oldval = newval;
16  retval = true;
17  }
18  return (retval);
19  }
20 
21  template<class T>
22  bool update_progress(const T& newval, T&oldval, const char* fn)
23  {
24  bool retval = update_progress(newval, oldval);
25  if (retval)
26  {
27  std::cout << fn << ": " << newval << "% complete." << std::endl;
28  }
29  return retval;
30  }
31 }
32 
33 #endif
bool update_progress(Tnewval &newval, Toldval &oldval)
Definition: update_progress.h:10