contrib/mul/mbl/mbl_progress_callback.h
Go to the documentation of this file.
00001 #ifndef mbl_progress_callback_h_
00002 #define mbl_progress_callback_h_
00003 
00004 
00005 //:
00006 // \file
00007 // \brief Assumes a hierarchy in the identifiers and reports a single float score to callback function.
00008 // \author Ian Scott
00009 // \date 04 Feb 2008
00010 
00011 
00012 #include <mbl/mbl_progress_hierarchy.h>
00013 
00014 
00015 //========================================================================
00016 //: Reports a single progress fraction to a C callback function.
00017 //
00018 // This class assumes that each progress identifier is arranged in a hierarchy,
00019 // and that calls to set_estimated_iterations and end_progress are correctly nested.
00020 class mbl_progress_callback: public mbl_progress_hierarchy
00021 {
00022  public:
00023   typedef void (*callback_ptr_t)(double progress);
00024 
00025   //: Pass in callback function pointer on construction.
00026   mbl_progress_callback (callback_ptr_t func): func_(func) {}
00027 
00028  protected:
00029 
00030   callback_ptr_t func_;
00031 
00032   //: Called when the progress has started, changed, or finished.
00033   // \param fraction Progress of all identifiers towards the end.
00034   // value is out of 1.0.
00035   virtual void on_changed_progress(double fraction)
00036   {
00037     (*func_)(fraction);
00038   }
00039 
00040 };
00041 
00042 
00043 #endif // mbl_progress_callback_h_