epoc32/include/lbspositioninfo.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __LBSPOSITIONINFO_H__
    17 #define __LBSPOSITIONINFO_H__
    18 
    19 #include <lbsposition.h>
    20 #include <lbscommon.h>
    21 #include <lbsfields.h>
    22 
    23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    24 class TPositionFieldIndex;
    25 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS
    26 
    27 
    28 /**
    29 The default size for a HPositionGenericInfo position information buffer
    30 
    31 @publishedAll
    32 @released
    33 */
    34 const TInt KPositionGenericInfoDefaultBufferSize = 1024;
    35 
    36 /**
    37 The default number of requested fields for a HPositionGenericInfo 
    38 position information buffer
    39 
    40 @publishedAll
    41 @released
    42 */
    43 const TInt KPositionGenericInfoDefaultMaxFields = 32;
    44 
    45 /**
    46 Position update types
    47 
    48 @publishedAll
    49 @released
    50  */
    51 enum _TPositionUpdateType
    52 	{
    53 	/** EPositionUpdateUnknown */
    54 	EPositionUpdateUnknown = 0,
    55 	/** EPositionUpdateGeneral */
    56 	EPositionUpdateGeneral = 0x01
    57 	};
    58 /**
    59 TPositionUpdateType code
    60 @publishedAll
    61 @released
    62  */
    63 typedef TUint32 TPositionUpdateType;
    64 
    65 
    66 /**
    67 Position mode reasons. These values summarise the reasons why module
    68 was unable to uses its preferred calculation mode when producing a 
    69 position update. The values are a bit mask that can be combined
    70 to describe the various reasons.
    71 
    72 NetworkError is used when there is no network coverage or
    73 the service is unavailable.
    74 
    75 LocalError represents environmental reasons that prevent a terminal
    76 based calculation - such as no satellites in view.
    77 
    78 DataError is returned when there is a problem with the initialisation
    79 data. For example, GPS assistance data was received but it was
    80 either invalid or could not be used..
    81 
    82 @publishedAll
    83 @released
    84  */
    85 enum _TPositionModeReason
    86 	{
    87 	/** Mode reason none */
    88 	EPositionModeReasonNone         = 0,
    89 	/** Mode reason network error */
    90 	EPositionModeReasonNetworkError = 1 << 0,
    91 	/** Mode reason local error */
    92 	EPositionModeReasonLocalError   = 1 << 1,
    93 	/** Mode reason data error */
    94 	EPositionModeReasonDataError    = 1 << 2
    95 	};
    96 
    97 /**
    98 TPositionModeReason code
    99 @publishedAll
   100 @released
   101  */
   102 typedef TUint32 TPositionModeReason;
   103 
   104 
   105 class TPositionInfoBase : public TPositionClassTypeBase
   106 /**
   107 This class provides the interface used by RPositioner to get a location fix,
   108 and as such all classes used to get location info from the location server should
   109 derive from this class.
   110 
   111 Class contains info about the update type and the ID of the module that gave the 
   112 location fix
   113 
   114 @publishedAll
   115 @released
   116  */
   117 	{
   118 public:
   119 	IMPORT_C TPositionModuleId ModuleId() const;
   120 	IMPORT_C void SetModuleId(TPositionModuleId aModuleId);
   121 
   122 	IMPORT_C TPositionUpdateType UpdateType() const;
   123 	IMPORT_C void SetUpdateType(TPositionUpdateType aUpdateType);
   124 
   125 	IMPORT_C TPositionModuleInfo::TTechnologyType PositionMode() const;
   126 	IMPORT_C void SetPositionMode(TPositionModuleInfo::TTechnologyType aMode);
   127 
   128 	IMPORT_C TPositionModeReason PositionModeReason() const;
   129 	IMPORT_C void SetPositionModeReason(TPositionModeReason aReason);
   130 
   131 protected:
   132 	IMPORT_C TPositionInfoBase();
   133 
   134 protected:
   135 	/** The Id of the module that gave the location fix. */
   136 	TPositionModuleId iModuleId;
   137 	/** The type of update that this location fix represents. */
   138 	TUint32 iUpdateType;
   139 
   140 	/** The positioning mode used to calculate this location fix. */
   141 	TPositionModuleInfo::TTechnologyType iPositionMode;
   142 
   143 	/** The reason why the prefered position mode was not used. */
   144 	TPositionModeReason iPositionModeReason;
   145 
   146 private:
   147 	/** Unused variable for future expansion. */
   148 	TUint8 iReserved[8];
   149 	};
   150 
   151 
   152 class TPositionInfo : public TPositionInfoBase
   153 /**
   154 Standard class for getting a TPosition location fix from the location server.
   155 
   156 @publishedAll
   157 @released
   158  */
   159 	{
   160 public:
   161 	IMPORT_C TPositionInfo();
   162 
   163 	IMPORT_C void GetPosition(TPosition& aPosition) const;
   164 	IMPORT_C void SetPosition(const TPosition& aPosition);
   165 
   166 protected:
   167 	/** The TPosition. */
   168 	TPosition iPosition;
   169 	};
   170 
   171 
   172 class TPositionCourseInfo : public TPositionInfo
   173 /**
   174 Class for getting a TCourse from the location server.
   175 
   176 @publishedAll
   177 @released
   178  */
   179 	{
   180 public:
   181 	IMPORT_C TPositionCourseInfo();
   182 
   183 	IMPORT_C void GetCourse(TCourse& aCourse) const;
   184 	IMPORT_C void SetCourse(const TCourse& aCourse);
   185 
   186 protected:
   187 	/** The TCourse. */
   188 	TCourse iCourse;
   189 	};
   190 
   191 
   192 /**
   193 Class for getting arbitrary positioning related information back from the location server. 
   194 The client can set upto KPositionMaxRequestedFields as the number of requested fields.
   195 The definitions of the fields are given in the enum #_TPositionFieldId. The client must 
   196 know what data type will be returned for each of the fields. The server will make a best 
   197 attempt to fill in the requested fields.
   198 
   199 The client needs to allocate a big enough buffer to store the information it is requesting.
   200 In order to be sure of getting back all the information the client must know and allocate 
   201 memory considering the return value for each requested field.
   202 
   203 @publishedAll
   204 @released
   205  */
   206 class HPositionGenericInfo : public TPositionInfo
   207 	{
   208 public:
   209 
   210 	IMPORT_C static HPositionGenericInfo* New(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
   211 											  TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
   212 	IMPORT_C static HPositionGenericInfo* NewL(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
   213 											   TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
   214 	IMPORT_C static HPositionGenericInfo* NewLC(TInt aBufferSize = KPositionGenericInfoDefaultBufferSize,
   215 												TInt aMaxFields = KPositionGenericInfoDefaultMaxFields);
   216 	IMPORT_C void ClearRequestedFields();
   217 	IMPORT_C TInt SetRequestedField(TPositionFieldId aFieldId);
   218 	IMPORT_C TInt SetRequestedFields(const TPositionFieldIdList aFieldIdList);
   219 	IMPORT_C TInt IsRequestedField(TPositionFieldId aFieldId) const;
   220 	IMPORT_C TPositionFieldId FirstRequestedFieldId() const;
   221 	IMPORT_C TPositionFieldId NextRequestedFieldId(TPositionFieldId aFieldId) const;
   222 	IMPORT_C TBool IsFieldAvailable(TPositionFieldId aFieldId) const;
   223 	IMPORT_C void ClearPositionData();	//Required on server side
   224 	IMPORT_C TInt BufferSize() const;
   225 	IMPORT_C TInt MaxFields() const;
   226 
   227     /**
   228      * Used to store position information.
   229      * @param aFieldId Standard position field identifier. See _TPositionFieldId
   230      * @param [in] aValue The parameter aValue can be of the type 
   231      * TInt8, TInt16, TInt32, TInt64, TUint8, TUint16, TUint32, 
   232      * TReal32, TReal64, TTime, TTimeIntervalMicroSeconds, Des8, or Des16.
   233      * @return a symbian OS error code.
   234      * @return KErrNone on successful operation.
   235      * @return KErrPositionBufferOverflow if the data contained in the 
   236      * parameter aValue cannot be added to the class due to the buffer being too small.
   237      */
   238 	template <class TType>
   239 		inline TInt SetValue(TPositionFieldId aFieldId, const TType& aValue) 
   240 			{return PositionFieldManager::SetValue(aFieldId, aValue, *this);}
   241 
   242     /**
   243      * Used to retrieve position information.
   244      * @param aFieldId Standard position field identifier. See _TPositionFieldId
   245      * @param [out] aValue The parameter aValue can be of the type 
   246      * TInt8, TInt16, TInt32, TInt64, TUint8, TUint16, TUint32, 
   247      * TReal32, TReal64, TTime, TTimeIntervalMicroSeconds, Des8, or Des16.
   248      * Panics with EPositionGenericInfoMismatchDataType if there is a 
   249      * mismatch in the data type of a field. 
   250      * @return a symbian OS error code.
   251      * @return KErrNone on successful operation.
   252      * @return KErrOverflow if the supplied descriptor is too short to contain the requested field.
   253      * This method must use the same data type as that assigned by SetValue() .
   254      */
   255 	template <class TType>
   256 		inline TInt GetValue(TPositionFieldId aFieldId, TType& aValue) const 
   257 			{return PositionFieldManager::GetValue(aFieldId, aValue, *this);}
   258 
   259 private:
   260 	HPositionGenericInfo(TInt aDataBufferSize, TInt aMaxFields, 
   261 		TUint aFieldIndexStartPoint, TUint aDataStartPoint, TBool aResetRequestedFields);
   262     /**
   263      * internal private method 
   264      */
   265 	HPositionGenericInfo& operator=(const HPositionGenericInfo&);
   266     /**
   267      * internal private method 
   268      */
   269 	HPositionGenericInfo(const HPositionGenericInfo&);
   270 
   271 	TInt FindEmptyRequestedFieldOffset(TInt& aEmptyFieldOffset) const;
   272 
   273     /**
   274      * Helper method. For internal usage only 
   275      */
   276 	inline TPositionFieldId* RequestedFieldPtr();
   277     /**
   278      * Helper method. For internal usage only 
   279      */
   280 	inline const TPositionFieldId* RequestedFieldPtr() const;
   281     /**
   282      * Helper method. For internal usage only 
   283      */
   284 	inline TPositionFieldIndex* FieldIndexPtr();
   285     /**
   286      * Helper method. For internal usage only 
   287      */
   288 	inline const TPositionFieldIndex* FieldIndexPtr() const;
   289 
   290 private:
   291 	friend class TPositionFieldSetter;
   292 	friend class TPositionFieldGetter;
   293 
   294 	/**	Max number of requesable/returnable fields. */
   295 	const TInt iMaxFields;
   296 
   297 	/** Offset into iBuffer of the field index. */
   298 	const TUint iFieldIndexStartPoint;
   299 
   300 	/** Offset into iBuffer of the actual location data. */
   301 	const TUint iDataStartPoint;
   302 
   303 	/** Total size of the buffer */
   304 	const TInt iTotalBufferSize;
   305 
   306 	/** Start of the buffer. The heap cell allocated for an instance of this class
   307 	has space for information up to iBuffer[iTotalBufferSize-1]*/
   308 	TUint8 iBuffer[1];	//Must be at end of class
   309 	};
   310 
   311 #endif //__LBSPOSITIONINFO_H__