ISIS Core Library 0.7.2 (api 3.0.0)
|
00001 /* 00002 <one line to give the program's name and a brief idea of what it does.> 00003 Copyright (C) <year> <name of author> 00004 00005 This program is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 00018 */ 00019 00020 #include "progressfeedback.hpp" 00021 #include "common.hpp" 00022 00023 namespace isis 00024 { 00025 namespace util 00026 { 00027 00028 ProgressFeedback &ProgressFeedback::operator++() 00029 { 00030 progress(); 00031 return *this; 00032 } 00033 00034 ProgressFeedback::~ProgressFeedback() {} 00035 00036 void ConsoleFeedback::show( size_t max, std::string header ) 00037 { 00038 header += "\n"; 00039 00040 if( disp ) 00041 extend( max ); 00042 else 00043 disp.reset( new boost::progress_display( max, std::cout, header ) ); 00044 } 00045 00046 size_t ConsoleFeedback::extend( size_t by ) 00047 { 00048 if( disp ) { 00049 long unsigned int at = disp->count(); 00050 disp->restart( disp->expected_count() + by ); 00051 return disp->operator+=( at ); 00052 } else { 00053 LOG( Debug, warning ) << "You should not use extend, if there is no progress bar shown already. (use show instead)"; 00054 show( by, "" ); 00055 return 0; 00056 } 00057 } 00058 00059 void ConsoleFeedback::close() 00060 { 00061 disp.reset(); 00062 } 00063 size_t ConsoleFeedback::getMax() 00064 { 00065 return disp ? disp->expected_count() : 0; 00066 } 00067 size_t ConsoleFeedback::progress( const std::string message, size_t step ) 00068 { 00069 LOG_IF( !disp, Debug, error ) << "Cannot call progress on a not displayed ConsoleFeedBack."; 00070 LOG_IF( !message.empty(), Debug, warning ) << "ConsoleFeedBack does ignore the message string"; 00071 return disp->operator+=( step ); 00072 } 00073 00074 00075 } 00076 }