locationtriggering/ltstrategyengine/inc/lbtstrategytimer.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2006, 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:  Class definition for Time Manager 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_LBTSTRATEGYTIMER_H
       
    21 #define C_LBTSTRATEGYTIMER_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "lbtmovementdetector.h" //Movt Detection
       
    27 
       
    28 
       
    29 /**
       
    30  * This is a helper class that is utilized by strategy engine to initiate 
       
    31  * requests for notification once a designated interval of time has elapsed.
       
    32  * This class also provides the interface to determine elapsed time 
       
    33  * (in microseconds). 
       
    34  */
       
    35 NONSHARABLE_CLASS( CLbtStrategyTimer ) : public CBase,
       
    36 										 public MLbtMovementObserver
       
    37     
       
    38     {
       
    39     
       
    40 public:
       
    41 
       
    42     /**
       
    43      * Factory function that instantiates an object of CLbtStrategyTimeManager
       
    44      */
       
    45     static CLbtStrategyTimer* NewL();
       
    46     
       
    47     /**
       
    48      * Destructor
       
    49      */
       
    50     ~CLbtStrategyTimer();
       
    51     
       
    52 public:
       
    53 
       
    54     /**
       
    55      * Initiates a request for notification after the specified time interval
       
    56      * has elapsed
       
    57      */
       
    58      void Set( TRequestStatus& aStatus, TTimeIntervalSeconds aSleepInterval,
       
    59                                        TBool aUtilizeMovementDetection );
       
    60      
       
    61      /** Movt Detection
       
    62      * Initiates a request for notification after the specified time interval
       
    63      * has elapsed
       
    64      */
       
    65      void ResetInterval( TRequestStatus& aStatus, TTimeIntervalSeconds aSleepInterval,
       
    66                                        TBool aUtilizeMovementDetection);
       
    67      
       
    68      /**
       
    69       * Cancels an outstanding request for notifications
       
    70       */
       
    71      void Cancel();
       
    72      
       
    73      /**
       
    74       * Determines the remaining sleep interval. This is calculated as 
       
    75       * estimated sleep time - (time when Set method was invoked - time when 
       
    76       * this method is invoked)
       
    77       */
       
    78      TBool RemainingSleepInterval( TTimeIntervalSeconds& aRemainingInterval );
       
    79       
       
    80      /**
       
    81       * Determines the remaining sleep interval. This is calculated as 
       
    82       * estimated sleep time - (time when Set method was invoked - time when 
       
    83       * this method is invoked)
       
    84       */
       
    85      TBool RemainingSleepInterval( TTimeIntervalSeconds aEstimatedTime, 
       
    86                                TTimeIntervalSeconds& aRemainingInterval );
       
    87                                
       
    88      /**
       
    89       * Determines if the sleep interval was interrupted during normal 
       
    90       * operations of strategy engine
       
    91       */
       
    92      TBool SleepIntervalInterrupted();
       
    93      
       
    94      /**
       
    95       *
       
    96       */
       
    97      void UtilizeMovementDetection( TBool aUsage = EFalse );
       
    98      
       
    99 private:
       
   100 
       
   101     /**
       
   102      * Default constructor
       
   103      */
       
   104     CLbtStrategyTimer();
       
   105     
       
   106     /**
       
   107      * 2nd phase constuctor for instantiating member variables
       
   108      */
       
   109     void ConstructL();
       
   110     
       
   111      /** 
       
   112      * Handles Movement detection notification 
       
   113      */
       
   114     void HandleDetectorNotification(const TMovementObserverEvent aEvent);
       
   115     
       
   116 private:
       
   117 
       
   118     /**
       
   119      * Timer instance used to generate notifications when a specified time
       
   120      * interval elapses
       
   121      */
       
   122     RTimer                      iTimer;
       
   123     
       
   124     /**
       
   125      * Sleep interval as specified by strategy engine
       
   126      */
       
   127     TTimeIntervalSeconds        iSleepTime;
       
   128     
       
   129     /**
       
   130      * Keeps track of the time when a request for timer notification is issued
       
   131      */
       
   132     TTime                       iStartTime;
       
   133     
       
   134     /**
       
   135      * Boolean flag to keep track of timer interrupts
       
   136      */
       
   137     TBool                       iInterrupt;
       
   138     
       
   139     //+Movt Detection
       
   140     /**
       
   141      * Will be initialized only if one of the following is true
       
   142      * 1) Movt detector is offline
       
   143      * 2) Movt detector has already notified the observer
       
   144      */
       
   145     TBool 				        iTimerInitialized;
       
   146     
       
   147     /*
       
   148      * Flag to indicate that movement has been detected
       
   149      */
       
   150     TBool 				        iMovtDetectorNotified;
       
   151     
       
   152     /*
       
   153      * Handle to the movement detector plugin
       
   154      */
       
   155     CLbtMovementDetector*       iMovtDetector;
       
   156     
       
   157     /*
       
   158      * Handle to the client TRequestStatus object
       
   159      */
       
   160     TRequestStatus*             iStatusPtr;
       
   161     
       
   162     /**
       
   163      *
       
   164      */
       
   165      TBool                      iUtilizeMovementDetection;
       
   166 	//-Movt Detection    
       
   167     };
       
   168 
       
   169 #endif  // C_LBTSTRATEGYTIMER_H