]> git.donarmstrong.com Git - mothur.git/blob - progress.cpp
*** empty log message ***
[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(){
22         try {
23                 cout << "********************#****#****#****#****#****#****#****#****#****#****#";
24                 
25                 nTicks = 0;
26                 finalPos = 0;
27         }
28         catch(exception& e) {
29                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
30                 exit(1);
31         }
32         catch(...) {
33                 cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
34                 exit(1);
35         }
36 }
37
38 /***********************************************************************/
39
40 Progress::Progress(string job, int end){
41         try {
42                 cout << "********************#****#****#****#****#****#****#****#****#****#****#\n";
43                 cout << setw(20) << left << job << setw(1) << marker;
44                 cout.flush();
45
46                 nTicks = 0;
47                 finalPos = end;
48         }
49         catch(exception& e) {
50                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
51                 exit(1);
52         }
53         catch(...) {
54                 cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
55                 exit(1);
56         }
57 }
58
59 /***********************************************************************/
60
61 void Progress::newLine(string job, int end){
62         try {
63                 cout << endl;
64                 cout << setw(20) << left << job << setw(1) << marker;
65                 cout.flush();
66                 
67                 nTicks = 0;
68                 finalPos = end;
69         }
70         catch(exception& e) {
71                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function newline. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
72                 exit(1);
73         }
74         catch(...) {
75                 cout << "An unknown error has occurred in the Progress class function newline. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
76                 exit(1);
77         }
78 }
79         
80 /***********************************************************************/
81
82 void Progress::update(const int currentPos){
83         try {
84                 int ratio = int(totalTicks * (float)currentPos / finalPos);
85         
86                 if(ratio > nTicks){
87                         for(int i=nTicks;i<ratio;i++){
88                                 cout << marker;
89                                 cout.flush();
90                         }
91                         nTicks = ratio;
92                 }
93         }
94         catch(exception& e) {
95                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
96                 exit(1);
97         }
98         catch(...) {
99                 cout << "An unknown error has occurred in the Progress class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
100                 exit(1);
101         }
102 }
103
104 /***********************************************************************/
105
106 void Progress::finish(){
107         try {
108                 for(int i=nTicks;i<totalTicks;i++){
109                         cout << marker;
110                         cout.flush();
111                 }
112         
113         
114                 cout << endl;
115                 cout << "***********************************************************************\n";
116                 cout.flush();
117         }
118         catch(exception& e) {
119                 cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
120                 exit(1);
121         }
122         catch(...) {
123                 cout << "An unknown error has occurred in the Progress class function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
124                 exit(1);
125         }
126 }
127
128 /***********************************************************************/