bluetoothengine/btaudioman/inc/basrvactive.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005-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:  The base active object declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_BASRVACTIVE_H
       
    20 #define C_BASRVACTIVE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 class CBasrvActive;
       
    26 
       
    27 /**
       
    28  * The observer of CBasrvActive's request events
       
    29  *
       
    30  * This class defines the interface to handle a async request events from CBasrvActive.
       
    31  *
       
    32  * @since S60 v3.1
       
    33  */
       
    34 class MBasrvActiveObserver
       
    35     {
       
    36     
       
    37 public:
       
    38 
       
    39     /**
       
    40      * Handles the request completion event.
       
    41      *
       
    42      * @since S60 v3.1
       
    43      * @param aActive the Active Object to which the request is assigned to.
       
    44      */
       
    45     virtual void RequestCompletedL(CBasrvActive& aActive) = 0;
       
    46     
       
    47     /**
       
    48      * Handles the cancellation of an outstanding request.
       
    49      *
       
    50      * @since S60 v3.1
       
    51      * @param aActive the Active Object to which the request is assigned to.
       
    52      */
       
    53     virtual void CancelRequest(CBasrvActive& aActive) = 0;
       
    54     
       
    55     };
       
    56 
       
    57 /**
       
    58  * A base class for abstract Active Objects.
       
    59  *
       
    60  * This class provides TRequestStatus for an async operation but it doesn't know the
       
    61  * detail of the request. CBasrvActive could be used to implement timers, P&S subscribes 
       
    62  * that are "simple" enough operations. 
       
    63  *
       
    64  * @since S60 v3.1
       
    65  */
       
    66 class CBasrvActive : public CActive
       
    67     {
       
    68     
       
    69 public:
       
    70 
       
    71     static CBasrvActive* New(MBasrvActiveObserver& aObserver, 
       
    72         CActive::TPriority aPriority, TInt aRequestId);
       
    73     
       
    74 
       
    75     static CBasrvActive* NewL(MBasrvActiveObserver& aObserver, 
       
    76         CActive::TPriority aPriority, TInt aRequestId);
       
    77 
       
    78     static CBasrvActive* NewLC(MBasrvActiveObserver& aObserver, 
       
    79         CActive::TPriority aPriority, TInt aRequestId);
       
    80 
       
    81     virtual ~CBasrvActive();
       
    82 
       
    83 public:
       
    84 
       
    85     /**
       
    86      * Calls SetActive().
       
    87      *
       
    88      * @since S60 v3.1
       
    89      */
       
    90     virtual void GoActive();
       
    91 
       
    92     /**
       
    93      * Gets the identifier of the request that this active object is serving.
       
    94      *
       
    95      * @since S60 v3.1
       
    96      * @return the request identifier
       
    97      */
       
    98     TInt RequestId() const;
       
    99     
       
   100     /**
       
   101      * Gets the identifier of the request that this active object is serving.
       
   102      *
       
   103      * @since S60 v3.1
       
   104      * @param the request identifier
       
   105      */
       
   106     void SetRequestId(TInt aRequestId);
       
   107 
       
   108 protected:
       
   109 
       
   110     /**
       
   111      * From CActive. 
       
   112      * cancels the outstanding request.
       
   113      *
       
   114      * @since S60 v3.1
       
   115      */
       
   116     virtual void DoCancel();
       
   117 
       
   118     /**
       
   119      * From CActive. 
       
   120      * Handles the request completion event.
       
   121      *
       
   122      * @since S60 v3.1
       
   123      */
       
   124     virtual void RunL();
       
   125 
       
   126     /**
       
   127      * From CActive. 
       
   128      * Handles the leave from RunL().
       
   129      *
       
   130      * @since S60 v3.1
       
   131      * @param aError the leave code in RunL()
       
   132      * @return the error code to Active Scheduler
       
   133      */
       
   134     virtual TInt RunError(TInt aError);
       
   135 
       
   136 protected:
       
   137 
       
   138     CBasrvActive(MBasrvActiveObserver& aObserver, 
       
   139         CActive::TPriority aPriority, TInt aRequestId);
       
   140 
       
   141     MBasrvActiveObserver& Observer();
       
   142 
       
   143 private:
       
   144 
       
   145     /**
       
   146      * The observer which is interested in the request handling events.
       
   147      * Not own.
       
   148      */
       
   149     MBasrvActiveObserver& iObserver;
       
   150     
       
   151     /**
       
   152      * The request identifier assigned to this active object.
       
   153      */
       
   154     TInt iRequestId;
       
   155     
       
   156     };
       
   157 
       
   158 #endif  // C_BASRVACTIVE_H