codhandler/codeng/inc/CodProgress.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *      Declaration of class TCodProgress.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef COD_PROGRESS_H
       
    22 #define COD_PROGRESS_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 
       
    28 // FORWARD DECLARATION
       
    29 
       
    30 class MCodLoadObserver;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 * Progress tracking.
       
    36 */
       
    37 NONSHARABLE_CLASS( TCodProgress )
       
    38     {
       
    39     public:     // types
       
    40     
       
    41         enum TPhase     ///< Progress phases.
       
    42             {
       
    43             ELoad = 0,  ///< Load phase.
       
    44             ENotify,    ///< Notify phase.
       
    45             ENumPhases  ///< End marker, do not use.
       
    46             };
       
    47 
       
    48     public:     // constructor
       
    49 
       
    50         /**
       
    51         * Constructor.
       
    52         * @param aObserver Observer.
       
    53         */
       
    54         inline TCodProgress( MCodLoadObserver* aObserver );
       
    55 
       
    56     public:     // new methods
       
    57 
       
    58         /**
       
    59         * Set or unset observer (pass NULL to unset).
       
    60         * Panics if already set; unsetting more is allowed.
       
    61         * @param aObserver Observer to set or NULL to unset.
       
    62         */
       
    63         void SetObserver( MCodLoadObserver* aObserver );
       
    64         
       
    65         /**
       
    66         * Setup progress.
       
    67         * aLoad Expected load bytes.
       
    68         * aNotify Expected notify bytes.
       
    69         */
       
    70         void Setup( TInt aLoad, TInt aNotify );
       
    71 
       
    72         /**
       
    73         * Start phase.
       
    74         * @param aPhase Phase.
       
    75         */
       
    76         void StartPhaseL( TPhase aPhase );
       
    77 
       
    78         /**
       
    79         * Data update (incremental).
       
    80         * @param aBytes Bytes received.
       
    81         */
       
    82         void IncrementL( TInt aBytes );
       
    83 
       
    84         /**
       
    85         * Data update (absolute).
       
    86         * @param aBytes Toal bytes received (in this phase).
       
    87         */
       
    88         void SetAmountL( TInt aBytes );
       
    89 
       
    90         /**
       
    91         * Set to complete.
       
    92         */
       
    93         void DoneL();
       
    94 
       
    95         /**
       
    96         * Get final value.
       
    97         * @return Final value.
       
    98         */
       
    99         inline TInt FinalValue();
       
   100 
       
   101         /**
       
   102         * Get current value.
       
   103         * @return Current value.
       
   104         */
       
   105         inline TInt CurrentValue();
       
   106 
       
   107     private:    // new methods
       
   108     
       
   109         /**
       
   110         * Progress update, notify observer.
       
   111         */
       
   112         inline void NotifyObserverL();
       
   113 
       
   114     private:    // data
       
   115 
       
   116         TPhase iPhase;                  ///< Current phase.
       
   117         TInt iMax[ENumPhases];          ///< Expected values.
       
   118         TInt iCur[ENumPhases];          ///< Realized values.
       
   119         MCodLoadObserver* iObserver;    ///< Observer. Not owned.
       
   120         
       
   121     };
       
   122 
       
   123 #include "CodProgress.inl"
       
   124 
       
   125 #endif /* def COD_PROGRESS_H */