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