hwrmhaptics/hapticspluginmanager/inc/hwrmhapticsgenerictimer.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Haptics generic timer class header file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_HWRMHAPTICSGENERICTIMER_H
       
    20 #define C_HWRMHAPTICSGENERICTIMER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 /**
       
    25  *  An interface for handling timer expiration events.
       
    26  * 
       
    27  * @since S60 5.1
       
    28  */
       
    29 class MHWRMHapticsGenericTimerCallback
       
    30     {
       
    31 public:
       
    32     /** 
       
    33      * Called when the timer fires
       
    34      *
       
    35      * @param aTimerId Timer identifier to id which timer fired.
       
    36      * @param aCutOff ETrue if timer firing occurred because maximum ontime
       
    37      *                was reached.
       
    38      */
       
    39     virtual void GenericTimerFired( TInt aTimerId, TBool aCutOff ) = 0;
       
    40     };
       
    41 
       
    42 /**
       
    43  *  Timer class for supervising Genericting time.
       
    44  */
       
    45 class CHWRMHapticsGenericTimer : public CTimer
       
    46     {
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Two-phased constructor.
       
    51      *
       
    52      * @param aCallback Callback object for informing timer firing
       
    53      * @param aMaxTime Maximum time timer is allowed to run. If 0 is used
       
    54      *        timer has no maximum time.
       
    55      * @param aTimerId Timer identifier used in timer fired callback.
       
    56      */
       
    57     static CHWRMHapticsGenericTimer* NewL(
       
    58             MHWRMHapticsGenericTimerCallback* aCallback,
       
    59             const TTimeIntervalMicroSeconds32& aMaxTime,
       
    60             TInt aTimerId );
       
    61      
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CHWRMHapticsGenericTimer();
       
    66 
       
    67     /**
       
    68      * Set the timer.
       
    69      *
       
    70      * @param aInterval timer will expire after this duration.
       
    71      *        If aInterval is zero, then timer is not started unless
       
    72      *        maximum time has been specified, in which case the 
       
    73      *        maximum time is used as duration.
       
    74      */
       
    75     void Set( const TTimeIntervalMicroSeconds32& aInterval );
       
    76 
       
    77     /**
       
    78      * Cancels the timer and returns the remaining time.
       
    79      * Timer can be resumed with Set call.
       
    80      *
       
    81      * @return Remaining time on timer. Will be Zero if timer is not active,
       
    82      *         otherwise it is always positive.
       
    83      */
       
    84     TTimeIntervalMicroSeconds32 Freeze();
       
    85 
       
    86 public:
       
    87 
       
    88     /**
       
    89      * From CTimer
       
    90      */
       
    91     void RunL();
       
    92         
       
    93 protected:
       
    94     
       
    95     /**
       
    96      * Constructor
       
    97      *
       
    98      * @param aCallback Callback object for informing timer firing
       
    99      * @param aMaxTime Maximum time timer is allowed to run. If 0 is used
       
   100      *        timer has no maximum time.
       
   101      * @param aTimerId Timer identifier used in timer fired callback.
       
   102      */
       
   103     CHWRMHapticsGenericTimer( MHWRMHapticsGenericTimerCallback* aCallback, 
       
   104                               const TTimeIntervalMicroSeconds32& aMaxTime,
       
   105                               TInt aTimerId );
       
   106         
       
   107 private: // Data
       
   108     
       
   109     /**
       
   110      * Callback for timer fired messages. Not owned.
       
   111      */
       
   112     MHWRMHapticsGenericTimerCallback* iCallback;
       
   113     
       
   114     /**
       
   115      * Maximum timer expiry time
       
   116      */
       
   117     TTimeIntervalMicroSeconds32 iMaximumTime;
       
   118     
       
   119     /**
       
   120      * Indicates whether the timer was cut off by max duration
       
   121      */
       
   122     TBool iCutOff;
       
   123     
       
   124     /**
       
   125      * Id of the timer
       
   126      */
       
   127     TInt iTimerId;
       
   128 
       
   129     /**
       
   130      * Stores the time the timer is set to activate
       
   131      */
       
   132     TTime iActivationTime;
       
   133     };
       
   134 
       
   135 #endif // C_HWRMHAPTICSGENERICTIMER_H   
       
   136             
       
   137 // End of File