TePDIPIManager.hpp

Go to the documentation of this file.
00001 /*
00002 TerraLib - a library for developing GIS applications.
00003 Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
00004 
00005 This code is part of the TerraLib library.
00006 This library is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU Lesser General Public
00008 License as published by the Free Software Foundation; either
00009 version 2.1 of the License, or (at your option) any later version.
00010 
00011 You should have received a copy of the GNU Lesser General Public
00012 License along with this library.
00013 
00014 The authors reassure the license terms regarding the warranties.
00015 They specifically disclaim any warranties, including, but not limited to,
00016 the implied warranties of merchantability and fitness for a particular
00017 purpose. The library provided hereunder is on an "as is" basis, and the
00018 authors have no obligation to provide maintenance, support, updates,
00019 enhancements, or modifications.
00020 In no event shall INPE be held liable to any party
00021 for direct, indirect, special, incidental, or consequential damages arising
00022 out of the use of this library and its documentation.
00023 */
00024 
00025 #ifndef TEPDIPIMANAGER_HPP
00026   #define TEPDIPIMANAGER_HPP
00027   
00028   #include "TePDIPIManagerGlobalSettings.hpp"
00029   
00030   #include "../kernel/TeProgress.h"
00031   
00032   #include <string>
00033 
00034   /**
00035    * @class TePDIPIManager
00036    * @brief This is the class for the active progress interface management.
00037    * @author Emiliano F. Castejon <castejon@dpi.inpe.br>
00038    * @note This class is not thread safe by itself but multiple threads
00039    * can access the global progress interface by instantiating their own
00040    * TePDIPIManager instances.
00041    * @ingroup PDIAux
00042    */
00043   class PDI_DLL TePDIPIManager {
00044   
00045     public :
00046     
00047       /**
00048        * @brief Default Constructor
00049        *
00050        * @param message Progress window message (label).
00051        * @param tsteps Progress window total steps.
00052        * @param enabled Flag to enable ( true ) or disable ( false ).
00053        */
00054       TePDIPIManager( const std::string& message = std::string(), 
00055         unsigned long int tsteps = 0, bool enabled = false );    
00056     
00057       /**
00058        * @brief Default Destructor
00059        */
00060       ~TePDIPIManager();
00061       
00062       /**
00063        * @brief Enable / Disable the current progress interface manager.
00064        *
00065        * @param enabled Flag to enable ( true ) or disable ( false ).
00066        */
00067       void Toggle( bool enabled );  
00068       
00069       /**
00070        * @brief Update the current progress interface to the supplied step.
00071        *
00072        * @param step Current step.
00073        * @return true if the interface was canceled, false otherwise.
00074        */
00075       bool Update( unsigned long int step );      
00076       
00077       /**
00078        * @brief Incriments the the current progress by one step.
00079        * @return true if the interface was canceled, false otherwise.
00080        */
00081       inline bool Increment()
00082       {
00083         return Update( (int)( curr_step_ + 1 ) );
00084       };
00085 
00086       /**
00087        * @brief Reset the current instance state.
00088        * 
00089        * @param message Message (label).
00090        * @param tsteps Total steps.
00091        */
00092       void Reset( const std::string& message = std::string(), 
00093         unsigned long int tsteps = 0 );
00094         
00095       /**
00096        * @brief Returns true if the progress was canceled.
00097        * @return Returns true if the progress was canceled.
00098        */
00099       inline bool wasCanceled()
00100       {
00101         return ( prog_intef_ptr_ ? prog_intef_ptr_->wasCancelled() : false );
00102       };         
00103         
00104     protected :
00105     
00106       /**
00107         * @brief A flag indicating if the PI manager is enabled.
00108         */
00109       bool enabled_;    
00110 
00111       /**
00112         * @brief The total steps number.
00113         */
00114       unsigned long int total_steps_;
00115 
00116       /**
00117         * @brief The current step.
00118         */
00119       unsigned long int curr_step_;
00120       
00121       /**
00122         * @brief A reference to the global settings instance.
00123         */      
00124       TePDIPIManagerGlobalSettings& global_settings_;
00125       
00126       /**
00127         * @brief A pointer to the active progress instance.
00128         * @note null if no active instance is present.
00129         */        
00130       TeProgressBase* prog_intef_ptr_;
00131       
00132       /**
00133         * @brief The progress interface message (label).
00134         */
00135       std::string message_;    
00136      
00137       /**
00138        * @brief Updates the progress interface with the new settings.
00139        * @note NO LOCK DONE !!
00140        * @param settings The new progress interface manager to be applied.
00141        * @param prog_intef_ptr Progres interface pointer.
00142        * @return true if the interface was canceled, false otherwise.
00143        */         
00144       bool updateProgressInterface() const;
00145         
00146     private :
00147     
00148       /**
00149        * @brief Alternative Constructor
00150        */    
00151       TePDIPIManager( const TePDIPIManager& );
00152       
00153       /**
00154        * @brief operator= overload.
00155        */    
00156       const TePDIPIManager& operator=( const TePDIPIManager& ) 
00157       { 
00158         return *this;
00159       };
00160   };
00161 
00162 #endif

Generated on Sun Jul 29 04:01:25 2012 for TerraLib - Development Source by  doxygen 1.5.3