contrib/mul/mbl/mbl_progress_composite.h
Go to the documentation of this file.
00001 #ifndef mbl_progress_composite_h_
00002 #define mbl_progress_composite_h_
00003 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00004 #pragma interface
00005 #endif
00006 
00007 
00008 //:
00009 // \file
00010 // \brief  A composite  of progress objects.
00011 // \author Graham Vincent
00012 // \date  25 Feb 2005
00013 
00014 
00015 #include <vcl_string.h>
00016 #include <vcl_vector.h>
00017 #include <vsl/vsl_binary_io.h>
00018 #include <mbl/mbl_progress.h>
00019 
00020 
00021 //=======================================================================
00022 //:  A composite  of progress objects.
00023 //
00024 // Individual progress objects are attached to an instance of
00025 // mbl_progress_composite which is passed to an algorithm.
00026 // The mbl_progress_composite will inform all attached progress objects
00027 // if and when it is informed of any progress.
00028 class mbl_progress_composite : public mbl_progress
00029 {
00030  public:
00031 
00032   //: Constructor
00033   mbl_progress_composite();
00034 
00035   //: Destructor
00036   virtual ~mbl_progress_composite();
00037 
00038   //: Adds a progress object to the composite.
00039   //  These are assumed to exist for the lifetime of this object.
00040   void add_progress(mbl_progress *progress);
00041 
00042   //: Version number for I/O
00043   short version_no() const;
00044 
00045   //: Name of the class
00046   virtual vcl_string is_a() const;
00047 
00048   //: Print class to os
00049   virtual void print_summary(vcl_ostream& ) const {}
00050 
00051  protected:
00052 
00053   //: Called when set_estimate_iterations() is called for a given identifier.
00054   //  \param identifier The operation being monitored.
00055   virtual void on_set_estimated_iterations(const vcl_string &identifier,
00056                                            const int total_iterations);
00057 
00058   //: Called when set_progress() is called for a given identifier.
00059   //  \param identifier The operation being monitored.
00060   //  \param progress The new progress status.
00061   virtual void on_set_progress(const vcl_string &identifier,
00062                                const int progress);
00063 
00064   //: Called when end_progress() is called for a given identifier.
00065   //  \param identifier The operation being monitored.
00066   virtual void on_end_progress(const vcl_string &identifier);
00067 
00068  private:
00069 
00070   //: Stores estimated iterations for each identifier
00071   vcl_vector<mbl_progress*> progress_objects_;
00072 };
00073 
00074 //=======================================================================
00075 
00076 #endif