datasourcemodules/simulationpositioningmodule/inc/EPos_CPosControllerBase.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 CPOSCONTROLLERBASE_H
       
    21 #define CPOSCONTROLLERBASE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <lbspositioninfo.h>
       
    26 
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class TPositionInfoBase;
       
    31 class CPosSimulationPositioner;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36  *  Base class for location request controllers.
       
    37  *
       
    38  *  Simulation PSY operates in different modes (NMEA and simulation mode) and
       
    39  *  the different functionality is handled by controller classes.
       
    40  *  CPosControllerBase is a base class to such controller classes.
       
    41  *
       
    42  *  @version $Revision: 1.5 $, $Date: 2005/03/17 07:07:04 $
       
    43  */
       
    44 class CPosControllerBase : public CActive
       
    45     {
       
    46     public:  // Constructors and destructor
       
    47 
       
    48         /**
       
    49         * Destructor.
       
    50         */
       
    51         ~CPosControllerBase();
       
    52 
       
    53     public: // New functions
       
    54 
       
    55         /**
       
    56         * Requests position info asynchronously.
       
    57         *
       
    58         * @param aPosInfo A reference to a position info object. This object
       
    59         *                 must be in scope until the request has completed.
       
    60         * @param aStatus The request status
       
    61         * @param aSimPos Positioner which called this function
       
    62         */
       
    63         virtual void NotifyPositionUpdate(
       
    64         /* IN/OUT */    TPositionInfoBase& aPosInfo,
       
    65         /* OUT    */    TRequestStatus& aStatus,
       
    66         /* IN     */	CPosSimulationPositioner& aSimPos
       
    67         )=0;	
       
    68         
       
    69         /**
       
    70         * Cancels position info request.
       
    71         * @param aSimPos Pointer to positioner which cancelled position update
       
    72         */
       
    73         virtual void CancelNotifyPositionUpdate(const CPosSimulationPositioner& aSimPos);
       
    74 
       
    75         void CompleteRequest( const TInt aIndex, TInt aErrorCode);
       
    76     protected:
       
    77 
       
    78         /**
       
    79         * C++ default constructor.
       
    80         */
       
    81         CPosControllerBase(TBool aTimeRelativePlayback);
       
    82         /**
       
    83 		* Requests position info asynchronously. Base implementation of NotifyPositionUpdate,
       
    84 		* should be called in all implementations of NotifyPositionUpdate in derived classes.
       
    85 		*
       
    86 		* @param aPosInfo A reference to a position info object. This object
       
    87 		*                 must be in scope until the request has completed.
       
    88 		* @param aStatus The request status
       
    89 		* @param aSimPos Pointer to positioner which called this function
       
    90 		*/
       
    91         void NotifyPositionUpdateBase(TPositionInfoBase& aPosInfo, TRequestStatus& aStatus, CPosSimulationPositioner& aSimPos);
       
    92         /**
       
    93          * Completes request and notifies all outstanding positioners with error code
       
    94          * @param aErrorCode Error code
       
    95          */
       
    96         void CompleteRequestBase(TInt aErrorCode);
       
    97         /**
       
    98 		 * Finds position of positioner in iSimulationPositioners array. Function panics if 
       
    99 		 * searched positioner is not found.
       
   100 		 * @param aSimPos positioner which should be found
       
   101 		 * @return Position in iSimulationPositioners array
       
   102 		 */
       
   103 		TInt FindPositioner(const CPosSimulationPositioner& aSimPos);
       
   104     private:
       
   105 
       
   106         // By default, prohibit copy constructor 
       
   107         CPosControllerBase( const CPosControllerBase& );
       
   108         // Prohibit assignment operator
       
   109         CPosControllerBase& operator= ( const CPosControllerBase& );
       
   110         /**
       
   111 		* Cancels all outstanding positions
       
   112 		*/
       
   113         void CancelAllNotifyPositionUpdate();
       
   114         
       
   115     protected:
       
   116     	/**
       
   117     	 * Helper class that holds reference information about registered positioners.
       
   118     	 * Class is used to store reference to positioners and to be able to check
       
   119     	 * on which positioners we have outstanding request to serve them.
       
   120     	 */
       
   121     	class TPositionerReference
       
   122     		{
       
   123     		public:
       
   124 				TPositionerReference(CPosSimulationPositioner& aSimPos,
       
   125 						TRequestStatus& aStatus,
       
   126 						TPositionInfo& aPosInfo):iSimPos(aSimPos),iReqStatus(aStatus), iPosition(aPosInfo){};
       
   127 				CPosSimulationPositioner&	iSimPos;
       
   128 				TRequestStatus&				iReqStatus;
       
   129 				TPositionInfo&				iPosition;
       
   130     		};
       
   131     protected:
       
   132     	/**
       
   133     	 * Array of registered positioners
       
   134     	 */
       
   135     	RArray<TPositionerReference>	iSimulationPositioners;
       
   136     	/**
       
   137     	 * Informs if time relative playback future is ON. ETrue - ON, EFalse - OFF.
       
   138     	 */
       
   139     	TBool	iTimeRelativePlayback;
       
   140     	/**
       
   141     	 * Defines time interval between reads in case of time relative playback.
       
   142     	 */
       
   143     	TTimeIntervalMicroSeconds32 iTimeBetweenReads;
       
   144     	/**
       
   145     	 * Position object, holds a local copy of position given
       
   146     	 * to positioners.
       
   147     	 */
       
   148     	TPositionInfo iPosition;
       
   149 
       
   150     };
       
   151 
       
   152 #endif      // CPOSCONTROLLERBASE_H
       
   153 
       
   154 // End of File