ISIS Core Library 0.7.2 (api 3.0.0)
|
00001 /* 00002 Copyright (C) 2010 reimer@cbs.mpg.de 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 #ifndef PROGRESSFEEDBACK_HPP 00020 #define PROGRESSFEEDBACK_HPP 00021 #include <stddef.h> 00022 #include <string> 00023 #include <boost/progress.hpp> 00024 #include <boost/scoped_ptr.hpp> 00025 00026 namespace isis 00027 { 00028 namespace util 00029 { 00030 /* 00031 * Basic class for any feedback given from longlasting processes about its progress (e.g. file loading) 00032 */ 00033 class ProgressFeedback: boost::noncopyable // ProgressFeedback should not be copyable - would break the progress counting 00034 { 00035 public: 00040 virtual void show( size_t max, std::string header = "" ) = 0; 00048 virtual size_t progress( const std::string message = "", size_t step = 1 ) = 0; 00050 virtual void close() = 0; 00052 virtual size_t getMax() = 0; 00054 virtual size_t extend( size_t by ) = 0; 00056 ProgressFeedback &operator++(); 00057 virtual ~ProgressFeedback(); 00058 }; 00059 00060 /* 00061 * Most simple implementation of a progress bar on the console 00062 */ 00063 class ConsoleFeedback: public ProgressFeedback 00064 { 00065 boost::scoped_ptr<boost::progress_display> disp; 00066 public: 00067 void close(); 00068 size_t getMax(); 00069 size_t progress( const std::string message = "", size_t step = 1 ); 00070 void show( size_t max, std::string header ); 00071 size_t extend( size_t by ); 00072 }; 00073 } 00074 } 00075 #endif // PROGRESSFEEDBACK_HPP