sensorservices/tiltcompensationssy/inc/tcstate.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  TTCState class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef TCSTATE_H
       
    21 #define TCSTATE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "tcevent.h"
       
    27 #include "tctransaction.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MTCStatePool;
       
    31 class MTCTransactionHandler;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 *  State base class.
       
    37 *
       
    38 *  @lib None
       
    39 *  @since S60 5.0
       
    40 */
       
    41 NONSHARABLE_CLASS( CTCState ): public CBase
       
    42     {
       
    43     public:
       
    44     
       
    45         /**
       
    46         * Tilt compensation SSY unique state type.
       
    47         * Invidual channels can have own states. Use this ID
       
    48         * to sepserate states from each others.
       
    49         */
       
    50         enum TCStateType
       
    51             {
       
    52             // UID for tilt channel states
       
    53             ETCStateTypeTilt = 0x01
       
    54             };
       
    55     
       
    56         /**
       
    57         * Tilt compensation SSY states.
       
    58         */
       
    59         enum TCStateId
       
    60             {
       
    61             ETCStateIdle,
       
    62             ETCStateOpen,
       
    63             ETCStateListenData,
       
    64             ETCStateBufferFull,
       
    65             ETCStateClosing,
       
    66             ETCStateLast
       
    67             };
       
    68             
       
    69     public:
       
    70     
       
    71         /**
       
    72         * Return state ID.
       
    73         * 
       
    74         * @return TTCStateId.
       
    75         */
       
    76         TCStateId Id() const;
       
    77         
       
    78         /**
       
    79         * The type of the state.
       
    80         * 
       
    81         * @return TCStateType
       
    82         */
       
    83         TCStateType Type() const;
       
    84 
       
    85     public:
       
    86     
       
    87         /**
       
    88         * State is requested to handle an event.
       
    89         * Event ID is mandatory, event data can be NULL.
       
    90         * 
       
    91         * @param aId event id
       
    92         * @param aEvent
       
    93         */
       
    94         virtual void HandleEventL( TTCEventId aId,
       
    95             TTCEvent* aEvent = NULL ) = 0;
       
    96     
       
    97         /**
       
    98         * Completed transactions are notified through here.
       
    99         * 
       
   100         * @parama TransactionId the transaction id
       
   101         * @param aError Symbian error codes
       
   102         * @return
       
   103         */
       
   104         virtual void HandleTransactionCompletedL(
       
   105             TTCTransactionId aTransactionId,
       
   106             TInt aError ) = 0;
       
   107     
       
   108         /**
       
   109         * Handle state entry.
       
   110         * This method is called when the state is entered.
       
   111         */
       
   112         virtual void HandleStateEntryL() = 0;
       
   113 
       
   114         /**
       
   115         * Handle state exit.
       
   116         * This method is called when the state is exit.
       
   117         */
       
   118         virtual void HandleStateExitL() = 0;
       
   119 
       
   120     protected: // New methods
       
   121     
       
   122         /**
       
   123         * Set a bit flag on.
       
   124         *
       
   125         * @param aFlag Bit flag to set.
       
   126         */
       
   127         void Set( TUint32 aFlag );
       
   128     
       
   129         /**
       
   130         * Unset a bit flag.
       
   131         *
       
   132         * @param aFlag Bit flag to unset.
       
   133         */
       
   134         void Unset( TUint32 aFlag );
       
   135 
       
   136         /**
       
   137         * Checks if specified bit flag is on.
       
   138         *
       
   139         * @param aFlag Bit flag to check.
       
   140         * @return ETrue if set.
       
   141         */
       
   142         TBool IsSet( TUint32 aFlag );
       
   143     
       
   144         /**
       
   145         * Clears all the bit flags.
       
   146         */
       
   147         void Clear();
       
   148 
       
   149     protected:
       
   150     
       
   151         /**
       
   152         * Default C++ constructor.
       
   153         *
       
   154         * @param aType
       
   155         * @param aId
       
   156         * @param aStatePool
       
   157         * @param aTransactionHandler
       
   158         */
       
   159         CTCState( TCStateType aType,
       
   160             TCStateId aId,
       
   161             MTCStatePool& aStatePool,
       
   162             MTCTransactionHandler& aTransactionHandler );
       
   163         
       
   164     protected: // Data
       
   165     
       
   166         /** State channel UID */
       
   167         TCStateType iType;
       
   168     
       
   169         /** State ID */
       
   170         TCStateId iId;
       
   171         
       
   172         /** Reference to state pool */
       
   173         MTCStatePool& iStatePool;
       
   174         
       
   175         /** Reference to transaction handler */
       
   176         MTCTransactionHandler& iTransactionHandler;
       
   177         
       
   178         /** Bit flag for internal state handling */
       
   179         TUint32 iFlags;
       
   180     };
       
   181     
       
   182 /** State array */
       
   183 typedef RPointerArray<CTCState> RStateArray;
       
   184 
       
   185 #endif // TCSTATE_H
       
   186 
       
   187 // End of File