1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef DBACCESS_PROGRESSMIXER_HXX 28 #define DBACCESS_PROGRESSMIXER_HXX 29 30 /** === begin UNO includes === **/ 31 /** === end UNO includes === **/ 32 33 #include <sal/types.h> 34 35 #include <memory> 36 37 //........................................................................ 38 namespace dbmm 39 { 40 //........................................................................ 41 42 typedef sal_uInt32 PhaseID; 43 typedef sal_uInt32 PhaseWeight; 44 45 //==================================================================== 46 //= IProgressConsumer 47 //==================================================================== 48 class SAL_NO_VTABLE IProgressConsumer 49 { 50 public: 51 virtual void start( sal_uInt32 _nRange ) = 0; 52 virtual void advance( sal_uInt32 _nValue ) = 0; 53 virtual void end() = 0; 54 }; 55 56 //==================================================================== 57 //= ProgressMixer 58 //==================================================================== 59 struct ProgressMixer_Data; 60 /** a class which mixes (i.e. concatenates) progress values from different 61 sources/phases, with different weight 62 */ 63 class ProgressMixer 64 { 65 public: 66 ProgressMixer( IProgressConsumer& _rConsumer ); 67 ~ProgressMixer(); 68 69 /** registers a phase of the process, which has the given weight 70 in the overall process 71 @precond 72 the progress is not runnig, yet 73 */ 74 void registerPhase( const PhaseID _nID, const PhaseWeight _nWeight ); 75 76 /** enters the phase with the given ID, with the phase having 77 the given overall range 78 */ 79 void startPhase( const PhaseID _nID, const sal_uInt32 _nPhaseRange ); 80 81 /** announces a new progress in the current phase. 82 83 The given phase progress must be between 0 and the overall phase range 84 as specified in ->startPhase. 85 */ 86 void advancePhase( const sal_uInt32 _nPhaseProgress ); 87 88 /** leaves the current phase, which has been started with ->startPhase previously 89 */ 90 void endPhase(); 91 92 private: 93 ::std::auto_ptr< ProgressMixer_Data > m_pData; 94 }; 95 96 //........................................................................ 97 } // namespace dbmm 98 //........................................................................ 99 100 #endif // DBACCESS_PROGRESSMIXER_HXX 101