TuttleOFX
1
|
00001 /** 00002 * @brief This file provides a set of member function that 00003 * are needed to manage algorithm progression. 00004 */ 00005 #ifndef _TUTTLE_PLUGIN_OFXPROGRESS_HPP_ 00006 #define _TUTTLE_PLUGIN_OFXPROGRESS_HPP_ 00007 00008 #include "IProgress.hpp" 00009 #include "exceptions.hpp" 00010 00011 #include <tuttle/plugin/global.hpp> 00012 #include <tuttle/plugin/IProgress.hpp> 00013 00014 #include <ofxsImageEffect.h> 00015 #include <ofxsMultiThread.h> 00016 00017 #include <string> 00018 00019 namespace tuttle { 00020 namespace plugin { 00021 00022 class OfxProgress : public IProgress 00023 { 00024 private: 00025 OFX::ImageEffect& _effect; ///< Used to access Ofx progress bar 00026 OFX::MultiThread::Mutex _mutex; 00027 OfxProgress& operator=( const OfxProgress& p ); 00028 00029 protected: 00030 double _stepSize; ///< Step size of progess bar 00031 double _counter; ///< Current position in [0; 1] 00032 00033 public: 00034 OfxProgress( OFX::ImageEffect& effect ) 00035 : _effect( effect ) 00036 , _mutex( 0 ) 00037 , _stepSize( 0 ) 00038 , _counter( 0 ) 00039 {} 00040 00041 virtual ~OfxProgress() {} 00042 00043 void progressBegin( const int numSteps, const std::string& msg = "" ); 00044 void progressEnd(); 00045 bool progressForward( const int nSteps ); 00046 00047 bool progressUpdate( const double p ); 00048 00049 OfxProgress& getOfxProgress() { return *this; } 00050 }; 00051 00052 } 00053 } 00054 00055 #endif