]> git.donarmstrong.com Git - mothur.git/blob - progress.cpp
fixed memory leak of groupmap in reads
[mothur.git] / progress.cpp
1 /*
2  *  progress.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 8/14/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10
11 #include "progress.hpp"
12
13 using namespace std;
14
15 const int totalTicks = 50;
16 const char marker = '|';
17
18
19 /***********************************************************************/
20
21 Progress::Progress(string job, int end){
22         try {
23                 cout << "********************#****#****#****#****#****#****#****#****#****#****#\n";
24                 cout << job << marker;
25                 cout.flush();
26         
27                 nTicks = 0;
28                 finalPos = end;
29         }
30         catch(exception& e) {
31                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
32                 exit(1);
33         }
34         catch(...) {
35                 cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
36                 exit(1);
37         }
38 }
39
40 /***********************************************************************/
41
42 void Progress::update(const int currentPos){
43         try {
44                 int ratio = int(totalTicks * (float)currentPos / finalPos);
45         
46                 if(ratio > nTicks){
47                         for(int i=nTicks;i<ratio;i++){
48                                 cout << marker;
49                                 cout.flush();
50                         }
51                         nTicks = ratio;
52                 }
53         }
54         catch(exception& e) {
55                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
56                 exit(1);
57         }
58         catch(...) {
59                 cout << "An unknown error has occurred in the Progress class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
60                 exit(1);
61         }
62 }
63
64 /***********************************************************************/
65
66 void Progress::finish(){
67         try {
68                 for(int i=nTicks;i<totalTicks;i++){
69                         cout << marker;
70                         cout.flush();
71                 }
72         
73         
74                 cout << endl;
75                 cout << "***********************************************************************\n";
76                 cout.flush();
77         }
78         catch(exception& e) {
79                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
80                 exit(1);
81         }
82         catch(...) {
83                 cout << "An unknown error has occurred in the Progress class function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
84                 exit(1);
85         }
86 }
87
88 /***********************************************************************/