ProgressReporterOld.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00026 #ifndef _APPBASE_POGRESSREPORTEROLD_H
00027 #define _APPBASE_POGRESSREPORTEROLD_H
00028 
00029 #include <hugin_shared.h>
00030 #include <string>
00031 #include <vector>
00032 #include <iostream>
00033 
00034 #include <appbase/ProgressDisplay.h>
00035 
00036 namespace AppBase
00037 {
00038     
00042     class IMPEX ProgressReporter
00043     {
00044     public:
00045         ProgressReporter(double maxProgress = 1.0);
00046         virtual ~ProgressReporter() {};
00047         
00048         virtual void setMessage(const std::string & msg) {};
00049         virtual bool increaseProgress(double delta) =0;
00050         
00051         virtual bool increaseProgress(double delta, const std::string& msg)
00052         {
00053             setMessage(msg);
00054             return increaseProgress(delta);
00055         }
00056         
00057     protected:
00058         double m_progress;
00059         double m_maxProgress;
00060     };
00061     
00062     
00066     class DummyProgressReporter : public ProgressReporter
00067     {
00068     public:
00069         DummyProgressReporter(double maxProgress = 1.0)
00070         : ProgressReporter(maxProgress)
00071         {};
00072         
00073         ~DummyProgressReporter() {};
00074         
00075         void setMessage(const std::string& msg) {};
00076         bool increaseProgress(double delta) { return true; };
00077     };
00078     
00079 
00083     class ProgressReporterAdaptor : public ProgressReporter
00084     {
00085     public:
00087         ProgressReporterAdaptor(ProgressDisplay& myProgressDisplay, const double& maxProgress);
00088            
00090         virtual ~ProgressReporterAdaptor();
00091         
00093         static ProgressReporter* newProgressReporter(ProgressDisplay* myProgressDisplay, const double& maxProgress);
00094         
00095     public:
00097         bool increaseProgress(double delta);
00098         
00100         void setMessage(const std::string & msg);
00101         
00102         
00103     protected:
00104         ProgressDisplay& o_progressDisplay;
00105     };
00106     
00107     
00108     
00110     class StreamProgressReporter : public ProgressReporter
00111     {
00112     public:
00114         StreamProgressReporter(double maxProgress, std::ostream & out=std::cout);
00115         
00117         virtual ~StreamProgressReporter();
00118         
00119     public:
00121         virtual bool increaseProgress(double delta);
00122         
00124         virtual bool increaseProgress(double delta, const std::string & msg);
00125         
00127         virtual void setMessage(const std::string & msg);
00128 
00130         void print();
00131         
00132     private:
00133         std::string m_message;
00134         std::ostream & m_stream;
00135     };
00136     
00137     
00138 } // namespace
00139 
00140 
00141 #endif // _H

Generated on Wed Aug 20 01:25:38 2014 for Hugintrunk by  doxygen 1.3.9.1