vtengines/videoteleng/Inc/Commands/CVtEngOperation.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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 "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:  Operation base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CVTENGOPERATION_H
       
    21 #define CVTENGOPERATION_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "vtengcommands.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CVtEngCommandHandler;
       
    29 class CVtEngHandlerContainer;
       
    30 class MVtEngOperationObserver;
       
    31 
       
    32 /**
       
    33 *  Operation base class.
       
    34 *
       
    35 *  @lib videoteleng
       
    36 *  @since 2.6
       
    37 */
       
    38 NONSHARABLE_CLASS( CVtEngOperation ) : public CBase
       
    39     {
       
    40     public: // constructor and destructors
       
    41 
       
    42         /**
       
    43         * two-phase constructor
       
    44         * @param aCommandId command id
       
    45         * @param aHandlers handler container
       
    46         * @param aObserver observer called back when operation is completed
       
    47         * @param aDelete if ETrue command deletes itself after completion
       
    48         */
       
    49         static CVtEngOperation* NewL(
       
    50             TVtEngCommandId aCommandId,
       
    51             CVtEngHandlerContainer& aHandlers,
       
    52             MVtEngOperationObserver& aObserver,
       
    53             TBool aDelete = ETrue );
       
    54 
       
    55         /**
       
    56         * Destructor
       
    57         */
       
    58         ~CVtEngOperation( );
       
    59 
       
    60     public: // new functions
       
    61 
       
    62         /**
       
    63         * Performs operations.
       
    64         * @return ETrue is operation is complete (i.e. sync).
       
    65         */
       
    66         virtual TBool ExecuteL( TDesC8* aParams );
       
    67 
       
    68         /**
       
    69         * Cancels pending command.
       
    70         * @return ETrue if cancelled was succesfull or there
       
    71         * is nothing to cancel.
       
    72         */
       
    73         TBool Cancel();
       
    74 
       
    75         /**
       
    76         * Returns command identifier.
       
    77         * @return command identifier
       
    78         */
       
    79         inline TVtEngCommandId Command() const;
       
    80 
       
    81         /**
       
    82         * Returns command parameter buffer.
       
    83         * @return parameter buffer
       
    84         */
       
    85         inline const TDesC8* Parameters() const;
       
    86 
       
    87         /**
       
    88         * Notifies observer on completion.
       
    89         * @param aResult Symbian OS error code
       
    90         */
       
    91         virtual void HandleOpComplete( const TInt aResult );
       
    92 
       
    93     protected: // new functions
       
    94 
       
    95         /**
       
    96         *
       
    97         */
       
    98         TBool OfferExecuteSyncL( TDesC8* aParams );
       
    99 
       
   100     protected:
       
   101         /**
       
   102         * c++ constructor
       
   103         */
       
   104         CVtEngOperation(
       
   105             TVtEngCommandId aCommandId,
       
   106             CVtEngHandlerContainer& aHandlers,
       
   107             MVtEngOperationObserver& aCommandHandler,
       
   108             TBool aDelete );
       
   109 	
       
   110 		/**
       
   111         * Handles asynchronous operation complete
       
   112         */
       
   113     	static TInt ASyncHandleOpComplete( TAny* aPtr );
       
   114 
       
   115     protected:
       
   116 
       
   117         // Command identifier
       
   118         const TVtEngCommandId   iCommand;
       
   119 
       
   120         // Handler container
       
   121         CVtEngHandlerContainer& iHandlers;
       
   122 
       
   123         // observer for command response
       
   124         MVtEngOperationObserver&   iObserver;
       
   125 
       
   126         // Parameter
       
   127         TDesC8*                 iParams;
       
   128 
       
   129         // Delete command when complete
       
   130         TBool                   iDelete;
       
   131 		
       
   132 		// Pointer to asynchronous callback
       
   133         CAsyncCallBack*         iAsyncCallback;
       
   134 
       
   135 		// Asynchronous callback error identifier
       
   136         TInt                    iAsyncErr;
       
   137     };
       
   138 
       
   139 /**
       
   140 * Utility class for unpacking data type with descriptor data.
       
   141 * @lib videoteleng
       
   142 * @since 2.6
       
   143 */
       
   144 template <class T>
       
   145 class TVtEngOpParamUtil
       
   146     {
       
   147     public:
       
   148         /**
       
   149         * Sets parameter in aDes to aRef.
       
   150         */
       
   151         inline void static Set( T& aRef , const CVtEngOperation& aOp );
       
   152     };
       
   153 
       
   154 #include    "CVtEngOperation.inl"
       
   155 
       
   156 #endif      // CVTENGOPERATION_H
       
   157 
       
   158 // End of File