datasourcemodules/simulationpositioningmodule/inc/EPos_CPosDataSimulationController.h
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CPOSDATASIMULATIONCONTROLLER_H
       
    21 #define CPOSDATASIMULATIONCONTROLLER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <lbspositioninfo.h>
       
    25 #include "EPos_TPosDataSimulator.h"
       
    26 #include "EPos_SimPsyConstants.h"
       
    27 #include "EPos_CPosControllerBase.h"
       
    28 #include "EPos_CPosSimulationPositioner.h"
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33  * A controller class that handles requests.
       
    34  *
       
    35  */
       
    36 class CPosDataSimController : public CPosControllerBase
       
    37     {
       
    38     public:  // Constructors and destructors
       
    39 
       
    40         enum TPosSimulationState
       
    41         {
       
    42         EPosCheckIfFailRequest,
       
    43         EPosTransferAndComplete
       
    44         };
       
    45 
       
    46         /**
       
    47         * Two-phased constructor.
       
    48         *
       
    49         * @param aSimulationFile The name of the simulation file to read from.
       
    50         * @param aTimeRelativePlayback turns object to work in time relative playback mode
       
    51         */
       
    52         static CPosDataSimController* NewL(
       
    53         /* IN  */       const TDesC& aSimulationFile,
       
    54         /* IN  */       TBool aTimeRelativePlayback
       
    55         );
       
    56 
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         virtual ~CPosDataSimController();
       
    61 
       
    62     public: // From base classes
       
    63 
       
    64         /**
       
    65         * From CPosControllerBase. Requests position info asynchronously.
       
    66         *
       
    67         * @param aPosInfo A reference to a position info object. This object
       
    68         *                 must be in scope until the request has completed.
       
    69         * @param aStatus The request status
       
    70         * @param aSimPos Reference to parent to call for request complete.
       
    71         */
       
    72         void NotifyPositionUpdate(
       
    73         /* IN/OUT */    TPositionInfoBase& aPosInfo,
       
    74         /* OUT    */    TRequestStatus& aStatus,
       
    75         /* IN     */	CPosSimulationPositioner& aSimPos
       
    76         );
       
    77 
       
    78         /**
       
    79         * From CPosControllerBase. Cancels position info request.
       
    80         * @param aSimPos Reference to parent who called this function
       
    81         */
       
    82         void CancelNotifyPositionUpdate(const CPosSimulationPositioner& aSimPos);
       
    83 
       
    84     private: // Constructors and destructor
       
    85 
       
    86         /**
       
    87         * C++ default constructor.
       
    88         * @param aTimeRelativePlayback turns object to work in time relative playback mode
       
    89         */
       
    90         CPosDataSimController(TBool aTimeRelativePlayback);
       
    91 
       
    92         /**
       
    93         * EPOC constructor.
       
    94         *
       
    95         * @param aSimulationFile The name of the simulation file to read from.
       
    96         */
       
    97         void ConstructL(
       
    98         /* IN  */       const TDesC& aSimulationFile
       
    99         );
       
   100 
       
   101         // Prohibit copy constructor
       
   102         CPosDataSimController( const CPosDataSimController& );
       
   103         // Prohibit assigment operator
       
   104         CPosDataSimController& operator= ( const CPosDataSimController& );
       
   105 
       
   106     private:  // New functions
       
   107 
       
   108         /**
       
   109         * Completes all requests with the specified error code
       
   110         * @param aErrorCode The error code - KErrNone if everything went OK.
       
   111         * If error code is something else, the position is invalid.
       
   112         */
       
   113         void CompleteRequest(TInt aErrorCode);
       
   114 
       
   115         /**
       
   116         * Sets completion code and waits for "Time to fix".
       
   117         */
       
   118         void SetCompletionCodeAndWait();
       
   119 
       
   120     private: // Functions from base classes
       
   121 
       
   122         /**
       
   123         * From CActive. Handles an active object’s request completion
       
   124         * event.
       
   125         */
       
   126         void RunL();
       
   127 
       
   128         /**
       
   129         * From CActive. Implements cancellation of an outstanding
       
   130         * request
       
   131         */
       
   132         void DoCancel();
       
   133 
       
   134         /**
       
   135         * From CActive. Handles a leave occurring in the request
       
   136         * completion event handler RunL()
       
   137         * @param aError The leave code
       
   138         */
       
   139         TInt RunError(TInt aError);
       
   140 
       
   141     private:    // Data
       
   142         TRequestStatus*           iRequestStatus;
       
   143         TPosition				  iSimulatedPosition;
       
   144         TPosition				  iBasePosition;
       
   145         TPosDataSimulator         iDataSimulator;
       
   146         TBuf8<KMaxSentenceLength> iInputBuffer;
       
   147         CDesC8Array*              iSimDataArray;
       
   148 
       
   149         TPosSimulationState       iSimulationState;
       
   150         TBool                     iSimulationInProcess;
       
   151         TInt                      iCompleteCode;
       
   152         TInt                      iNumRequests;
       
   153         TTime                     iRequestStartTime;
       
   154         TTime                     iLastRequestTime;
       
   155 
       
   156         RTimer                    iTimer;
       
   157     };
       
   158 
       
   159 #endif      // CPOSDATASIMCONTROLLER_H
       
   160 
       
   161 // End of File