contrib/mul/mbl/mbl_progress_time.h
Go to the documentation of this file.
00001 #ifndef mbl_progress_time_h_
00002 #define mbl_progress_time_h_
00003 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00004 #pragma interface
00005 #endif
00006 
00007 
00008 //:
00009 // \file
00010 // \brief Progress class that outputs elapsed time reporting on progress
00011 // \author Kevin de Souza
00012 // \date 26 June 2008
00013 
00014 
00015 #include <vcl_iostream.h>
00016 #include <vul/vul_timer.h>
00017 #include <vul/vul_ios_state.h>
00018 #include <mbl/mbl_progress.h>
00019 
00020 
00021 //========================================================================
00022 //: \brief Progress class that outputs elapsed time reporting on progress
00023 class mbl_progress_time : public mbl_progress
00024 {
00025 public:
00026 
00027   //: Constructor
00028   // \param os Ostream for text output (defaults to cout)
00029   mbl_progress_time(vcl_ostream& os=vcl_cout);
00030 
00031   //: Destructor
00032   ~mbl_progress_time();
00033 
00034   //: Name of the class
00035   virtual vcl_string is_a() const;
00036 
00037 
00038 protected:
00039 
00040   //: Called when set_estimate_iterations() is called for a given identifier.
00041   //  \param identifier The operation being monitored.
00042   virtual void on_set_estimated_iterations(const vcl_string& identifier,
00043                                            const int total_iterations);
00044 
00045   //: Called when set_progress() is called for a given identifier.
00046   //  \param identifier The operation being monitored.
00047   //  \param progress The new progress status.
00048   virtual void on_set_progress(const vcl_string& identifier,
00049                                const int progress);
00050 
00051   //: Called when end_progress() is called for a given identifier.
00052   //  \param identifier The operation being monitored.
00053   virtual void on_end_progress(const vcl_string &identifier);
00054 
00055 
00056 protected:
00057 
00058   vcl_ostream& os_;
00059   vul_timer timer_;
00060   vul_ios_state_saver ios_state_; // Restores stream format after this progress object is destroyed
00061 };
00062 
00063 //========================================================================
00064 
00065 #endif // mbl_progress_time_h_