X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=progress.cpp;h=ff93b348e521009fac30e72bc3e0c34f46327400;hp=94ad41607064445a2307e5fcd2298403de8424a5;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=20a2d0350a737a434c89f303662d64a8eeea7b05 diff --git a/progress.cpp b/progress.cpp index 94ad416..ff93b34 100644 --- a/progress.cpp +++ b/progress.cpp @@ -7,38 +7,70 @@ * */ -#include -#include -#include "progress.hpp" -#include -using namespace std; +#include "progress.hpp" const int totalTicks = 50; const char marker = '|'; +/***********************************************************************/ + +Progress::Progress(){ + try { + m = MothurOut::getInstance(); + m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#"); + + nTicks = 0; + finalPos = 0; + } + catch(exception& e) { + m->errorOut(e, "Progress", "Progress"); + exit(1); + } +} + /***********************************************************************/ Progress::Progress(string job, int end){ try { - cout << "*******************#****#****#****#****#****#****#****#****#****#****#\n"; - cout << job << marker; + m = MothurOut::getInstance(); + + m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#\n"); + cout << setw(20) << left << job << setw(1) << marker; + m->mothurOutJustToLog(job); + m->mothurOut(toString(marker)); cout.flush(); - + nTicks = 0; finalPos = end; + } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "Progress", "Progress"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the Progress class function Progress. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; +} + +/***********************************************************************/ + +void Progress::newLine(string job, int end){ + try { + m->mothurOutEndLine(); + cout << setw(20) << left << job << setw(1) << marker; + m->mothurOutJustToLog(job); + m->mothurOut(toString(marker)); + cout.flush(); + + nTicks = 0; + finalPos = end; + } + catch(exception& e) { + m->errorOut(e, "Progress", "newLine"); exit(1); } } - + /***********************************************************************/ void Progress::update(const int currentPos){ @@ -47,18 +79,14 @@ void Progress::update(const int currentPos){ if(ratio > nTicks){ for(int i=nTicks;imothurOut(toString(marker)); cout.flush(); } nTicks = ratio; } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Progress class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "Progress", "update"); exit(1); } } @@ -68,21 +96,17 @@ void Progress::update(const int currentPos){ void Progress::finish(){ try { for(int i=nTicks;imothurOut(toString(marker)); cout.flush(); } - cout << endl; - cout << "**********************************************************************\n"; + m->mothurOutEndLine(); + m->mothurOut("***********************************************************************\n"); cout.flush(); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Progress class Function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Progress class function finish. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "Progress", "finish"); exit(1); } }