// ----------------------------------------------------------------------- // feedback.cc: Member functions for the ProgressBar class. // ----------------------------------------------------------------------- // Copyright (C) 2006, Matthew Whiting, ATNF // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your // option) any later version. // // Duchamp is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License // along with Duchamp; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA // // Correspondence concerning Duchamp may be directed to: // Internet email: Matthew.Whiting [at] atnf.csiro.au // Postal address: Dr. Matthew Whiting // Australia Telescope National Facility, CSIRO // PO Box 76 // Epping NSW 1710 // AUSTRALIA // ----------------------------------------------------------------------- #include #include #include void printBackSpace(std::ostream &stream, int num) { for(int i=0;i(i*stepSize)) numNeeded++; if(numNeeded != numVisible){ numVisible = numNeeded; if(loc==END) printBackSpace(length+2); std::cout << "|"; printHash(numNeeded); printSpace(length-numNeeded); std::cout << "|" << std::flush; loc=END; } } void ProgressBar::rewind() { /// @details /// If we are at the end, we print out enough backspaces to wipe out /// the entire bar. If we are not, the erasing does not need to be /// done. if(loc==END) printBackSpace(length+2); loc=BEG; std::cout << std::flush; } void ProgressBar::remove() { /// @details /// We first rewind() to the beginning, overwrite the bar with blank spaces, /// and then rewind(). We end up at the beginning. rewind(); printSpace(length+2); loc=END; rewind(); std::cout << std::flush; } void ProgressBar::fillSpace(std::string someString) { /// @details /// We first remove() the bar and then write out the requested string. /// \param someString The string to be written over the bar area. remove(); std::cout << someString; loc=END; }