lbscommon.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : LbsCommon.h
00004 *  Part of     : Location Framework/Location FW
00005 *  Interface   : Location Acquisition API
00006 *  Description : Common classes
00007 *  Version     : %version: 6 %
00008 *
00009 *  Copyright (c) 2002-2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation. All rights are reserved. Copying,
00013 *  including reproducing, storing, adapting or translating, any
00014 *  or all of this material requires the prior written consent of
00015 *  Nokia Corporation. This material also contains confidential
00016 *  information which may not be disclosed to others without the
00017 *  prior written consent of Nokia Corporation.
00018 * ==============================================================================
00019 */
00020 
00021 #ifndef __LBSCOMMON_H__
00022 #define __LBSCOMMON_H__
00023 
00024 #include <e32std.h>
00025 #include <e32math.h>
00026 #include <LbsRequestor.h>
00027 #include <LbsClassTypes.h>
00028 #include <LbsErrors.h>
00029 
00036 // A compile time assert macro. The aExpr parameter must evaluate to a
00037 // positive integer value at compile time.
00038 // eg. sizeof(TTime) == KSizeOfTInt64
00039 // If aExpr is false, the compiler generates an error.
00040 // If aExpr is true, the compilation continues, and use of this macro will not
00041 // result in any extra object code.
00042 #define POSITION_COMPILE_TIME_ASSERT(aExpr)   typedef char assert_type[(aExpr) ? 1 : -1]
00043 
00047 const TInt KPositionMaxModuleName = 64;
00048 
00053 const TUint KPositionMaxSizeQualityItem = sizeof(TInt64);
00054 
00059 const TUint KPositionMaxSectionFields = 10;
00060 
00065 typedef TUid  TPositionModuleId;
00066 
00070 const TPositionModuleId KPositionNullModuleId = {KNullUidValue};
00071 
00072 
00076 class TPositionClassTypeBase
00077         {
00078 public:
00083         IMPORT_C TUint32 PositionClassType() const;
00084 
00089         IMPORT_C TUint PositionClassSize() const;
00090 
00091 protected:
00092         TPositionClassTypeBase();
00093 
00094 protected:
00096         TUint32 iPosClassType;
00098         TUint iPosClassSize;
00099         };
00100 
00101 
00108 class TPositionQualityItem
00109         {
00110 public:
00112         enum TResult
00113                 {
00115                 EIsBetter, 
00117                 EIsEqual,
00119                 EIsWorse
00120                 };
00121 
00122         enum TValuePreference
00123                 {
00124                 EPreferSmallerValues,
00125                 EPreferGreaterValues
00126                 };
00127 
00129         enum TDataType
00130                 {
00131                 EUndefined, 
00132                 ETInt8,     
00133                 ETInt16,    
00134                 ETInt32,    
00135                 ETInt64,    
00136                 ETUint8,    
00137                 ETUint16,   
00138                 ETUint32,   
00139                 ETReal32,   
00140                 ETReal64,   
00141                 ETTime,     
00142                 ETTimeIntervalMicroSeconds 
00143                 };
00144 
00145         TPositionQualityItem();
00146 
00147         TInt Compare(const TPositionQualityItem& aItem, TResult& aComparison) const;
00148 
00149         void Set(TDataType aDataType, TValuePreference aValuePreference,
00150                          const TAny* aData, TUint aSizeOfData);
00151 
00152         TInt Get(TDataType aDataType, TAny* aData, TUint aSizeOfData) const;
00153 
00154         TBool IsDefined() const;
00155 
00156 private:
00157         TDataType iDataType;
00158         TValuePreference iScaleDirection;
00159         TUint8 iData[KPositionMaxSizeQualityItem];
00160         };
00161 
00165 class TPositionQualityBase : public TPositionClassTypeBase
00166         {
00167 public:
00168 
00180         IMPORT_C TInt Compare(const TPositionQualityBase& aPositionQuality,
00181                                                   TInt aElementToCompare,
00182                                                   TPositionQualityItem::TResult& aComparison) const;
00183 
00188         IMPORT_C TBool IsDefined(TInt aElementId) const;
00189 
00193         IMPORT_C TInt HighWaterMark() const;
00194 protected:
00195         IMPORT_C TPositionQualityBase();
00196 
00197         IMPORT_C void ResetElement(TInt aElementId);
00198 
00199         template <class T>
00200                 inline void SetElement(TInt aElementId, TPositionQualityItem::TDataType aDataType,
00201                                                            TPositionQualityItem::TValuePreference aValuePreference, T aData)
00202                 {DoSetElement(aElementId, aDataType, aValuePreference, &aData, sizeof(T));}
00203         
00204         template <class T>
00205                 inline TInt GetElement(TInt aElementId, TPositionQualityItem::TDataType aDataType,
00206                                                             T& aData) const
00207                 {return DoGetElement(aElementId, aDataType, &aData, sizeof(T));}
00208 
00209 private:
00210         IMPORT_C void DoSetElement(TInt aElementId, TPositionQualityItem::TDataType aDataType,
00211                                                            TPositionQualityItem::TValuePreference aValuePreference,
00212                                                            const TAny* aData, TUint aSizeOfData);
00213 
00214         IMPORT_C TInt DoGetElement(TInt aElementId, TPositionQualityItem::TDataType aDataType,
00215                                                                 TAny* aData, TUint aSizeOfData) const;
00216 private:
00217         TFixedArray<TPositionQualityItem, KPositionMaxSectionFields> iPositionQualityData;
00218         TInt iHighwaterMark;
00219         };
00220 
00224 class TPositionQuality : public TPositionQualityBase
00225         {
00226 public:
00231         enum TCostIndicator
00232                 {
00234                 ECostUnknown,
00239                 ECostZero,
00245                 ECostPossible,
00251                 ECostCharge
00252                 };
00253 
00258         enum TPowerConsumption
00259                 {
00264                 EPowerUnknown,
00269                 EPowerZero,
00275                 EPowerLow,
00281                 EPowerMedium,
00287                 EPowerHigh
00288                 };
00289 
00290 public:
00295         IMPORT_C TPositionQuality();
00296 
00303         IMPORT_C TTimeIntervalMicroSeconds TimeToFirstFix() const;
00304 
00311         IMPORT_C TTimeIntervalMicroSeconds TimeToNextFix()  const;  
00312 
00323         IMPORT_C TReal32 HorizontalAccuracy() const;
00324 
00335         IMPORT_C TReal32 VerticalAccuracy()   const;
00336 
00342         IMPORT_C TCostIndicator CostIndicator() const;
00343 
00349         IMPORT_C TPowerConsumption PowerConsumption() const;
00350 
00356         IMPORT_C void SetTimeToFirstFix(TTimeIntervalMicroSeconds aTimeToFirstFix);
00357 
00363         IMPORT_C void SetTimeToNextFix(TTimeIntervalMicroSeconds aTimeToNextFix);
00364 
00370         IMPORT_C void SetHorizontalAccuracy(TReal32 aHorizontalAccuracy);
00371 
00377         IMPORT_C void SetVerticalAccuracy(TReal32 aVerticalAccuracy);
00378 
00384         IMPORT_C void SetCostIndicator(TCostIndicator aCost);
00385 
00391         IMPORT_C void SetPowerConsumption(TPowerConsumption aPower);
00392 
00393 private:
00395         TUint8 iReserved[16];
00396         };
00397 
00398 
00402 class TPositionModuleInfoBase : public TPositionClassTypeBase
00403         {
00404 protected:
00405         IMPORT_C TPositionModuleInfoBase();
00406         };
00407 
00411 class TPositionModuleInfo : public TPositionModuleInfoBase
00412         {
00413 public:
00414 
00420         typedef TUint32 TTechnologyType;
00424         enum _TTechnologyType
00425                 {
00430                 ETechnologyUnknown      = 0,
00434                 ETechnologyTerminal     = 0x01,
00438                 ETechnologyNetwork      = 0x02,
00443                 ETechnologyAssisted     = 0x04
00444                 };
00445 
00451         typedef TUint32 TDeviceLocation;
00455         enum _TDeviceLocation
00456                 {
00461                 EDeviceUnknown  = 0,
00465                 EDeviceInternal = 0x01,
00469                 EDeviceExternal = 0x02
00470                 };
00471 
00477         typedef TUint32 TCapabilities;
00481         enum _TCapabilities
00482                 {
00484                 ECapabilityNone        = 0,
00490                 ECapabilityHorizontal  = 0x0001,
00496                 ECapabilityVertical    = 0x0002,
00502                 ECapabilitySpeed       = 0x0004,
00508                 ECapabilityDirection   = 0x0008,
00514                 ECapabilitySatellite   = 0x0010,
00519                 ECapabilityCompass     = 0x0020,
00524                 ECapabilityNmea        = 0x0040,
00530                 ECapabilityAddress     = 0x0080,
00535                 ECapabilityBuilding    = 0x0100,
00541                 ECapabilityMedia       = 0x0200
00542                 };
00543 
00544 public:
00548         IMPORT_C TPositionModuleInfo();
00549 
00554         IMPORT_C TPositionModuleId ModuleId() const;
00555 
00562         IMPORT_C TBool IsAvailable() const;
00563 
00568         IMPORT_C void GetModuleName(TDes& aModuleName) const;
00569 
00575         IMPORT_C void GetPositionQuality(TPositionQuality& aPosQuality) const;
00576 
00583         IMPORT_C TTechnologyType TechnologyType() const;
00584 
00590         IMPORT_C TDeviceLocation DeviceLocation() const;
00591 
00597         IMPORT_C TCapabilities Capabilities() const ;
00598 
00612         IMPORT_C TUint32 ClassesSupported(TPositionClassFamily aClassType) const;
00613 
00618         IMPORT_C TVersion Version() const;
00619 
00626         IMPORT_C void SetModuleId(TPositionModuleId aModuleId);
00627 
00635         IMPORT_C void SetIsAvailable(TBool aIsAvailable);
00636 
00643         IMPORT_C void SetModuleName(const TDesC& aModuleName);
00644 
00652         IMPORT_C void SetPositionQuality(const TPositionQuality& aPosQuality);
00653 
00662         IMPORT_C void SetTechnologyType(TTechnologyType aTechnologyType);
00663 
00671         IMPORT_C void SetDeviceLocation(TDeviceLocation aDeviceLocation);
00672 
00680         IMPORT_C void SetCapabilities(TCapabilities aDeviceCapabilities);
00681 
00692         IMPORT_C void SetClassesSupported(TPositionClassFamily aClassType,
00693                                                                           TUint32 aSupportedClasses);
00694 
00701         IMPORT_C void SetVersion(TVersion aVersion);
00702 
00703 protected:
00705         TPositionModuleId       iModuleId;
00707         TBool iIsAvailable;
00709         TBuf<KPositionMaxModuleName> iModuleName;
00711         TPositionQuality    iPosQuality;
00713         TTechnologyType     iTechnologyType;
00715         TDeviceLocation     iDeviceLocation;
00717         TCapabilities           iCapabilities;
00719         TFixedArray<TUint32, EPositionLastFamily> iSupportedClassTypes;
00721         TVersion            iVersion;
00722 
00723 private:
00725         TUint8 iReserved[16];
00726         };
00727 
00728 
00732 class TPositionModuleStatusBase : public TPositionClassTypeBase
00733         {
00734 protected:
00735         IMPORT_C TPositionModuleStatusBase();
00736         };
00737 
00741 class TPositionModuleStatus : public TPositionModuleStatusBase
00742         {
00743 public:
00744 
00749         typedef TInt TDeviceStatus;
00750 
00754         enum _TDeviceStatus 
00755                 {
00757                 EDeviceUnknown,
00759                 EDeviceError,
00765                 EDeviceDisabled,
00770                 EDeviceInactive,
00778                 EDeviceInitialising,
00787                 EDeviceStandBy,
00792                 EDeviceReady,
00797                 EDeviceActive
00798                 };
00799 
00804         typedef TInt TDataQualityStatus;
00805 
00809         enum _TDataQualityStatus
00810                 {
00816                 EDataQualityUnknown,
00826                 EDataQualityLoss,
00832                 EDataQualityPartial,
00834                 EDataQualityNormal
00835                 };
00836 
00840         IMPORT_C TPositionModuleStatus();
00841 
00846         IMPORT_C TDeviceStatus DeviceStatus() const;
00847 
00853         IMPORT_C TDataQualityStatus DataQualityStatus() const;
00854 
00861         IMPORT_C void SetDeviceStatus(TDeviceStatus aStatus);
00862 
00869         IMPORT_C void SetDataQualityStatus(TDataQualityStatus aStatus);
00870         
00871 protected:
00873         TDeviceStatus      iDeviceStatus;
00875         TDataQualityStatus iDataQualityStatus;
00876 
00877 private:
00879         TUint8 iReserved[8];
00880         };
00881 
00882 
00886 class TPositionModuleStatusEventBase : public TPositionClassTypeBase
00887         {
00888 public:
00894         typedef TUint32 TSystemModuleEvent;
00895 
00899         enum _TSystemModuleEvent
00900                 {
00902                 ESystemUnknown                          = 0,
00907                 ESystemError,
00912                 ESystemModuleInstalled,
00914                 ESystemModuleRemoved
00915                 };
00916         
00923         typedef TUint32 TModuleEvent;
00924 
00928         enum _TModuleEvent
00929                 {
00931                 EEventNone                              = 0,
00933                 EEventDeviceStatus      = 0x01,
00935                 EEventDataQualityStatus = 0x02,
00937                 EEventSystemModuleEvent = 0x04,
00939                 EEventAll                               = EEventDeviceStatus |
00940                                                                   EEventDataQualityStatus |
00941                                                                   EEventSystemModuleEvent
00942                 };
00943 
00944 protected:
00948         IMPORT_C TPositionModuleStatusEventBase();
00956         IMPORT_C TPositionModuleStatusEventBase(TModuleEvent aRequestedEventMask);
00957 
00958 public:
00965         IMPORT_C void SetRequestedEvents(TModuleEvent aRequestedEventMask);
00966 
00971         IMPORT_C TModuleEvent RequestedEvents() const;
00972 
00979         IMPORT_C void SetOccurredEvents(TModuleEvent aOccurredEventMask);
00980 
00992         IMPORT_C TModuleEvent OccurredEvents() const;
00993 
00998         IMPORT_C TPositionModuleId ModuleId() const;
00999 
01006         IMPORT_C void SetModuleId(TPositionModuleId aModuleId);
01007 
01014         IMPORT_C void SetSystemModuleEvent(TSystemModuleEvent aSystemModuleEvent);
01015 
01020         IMPORT_C TSystemModuleEvent SystemModuleEvent() const;
01021 
01022 protected:
01023         IMPORT_C virtual void DoReset(TInt aSizeOfClass);
01024 
01025 private:
01026         friend class RPositionServer;
01027         void Reset();
01028 
01029 protected:
01031         TModuleEvent iRequestedEvents;
01033         TModuleEvent iOccurredEvents;
01035         TSystemModuleEvent iSystemModuleEvent;
01037         TPositionModuleId  iModuleId;
01038         };
01039 
01043 class TPositionModuleStatusEvent : public TPositionModuleStatusEventBase
01044         {
01045 public:
01049         IMPORT_C TPositionModuleStatusEvent();
01050 
01056         IMPORT_C TPositionModuleStatusEvent(TModuleEvent aRequestedEventMask);
01057 
01065         IMPORT_C void SetModuleStatus(const TPositionModuleStatus& aModuleStatus);
01066 
01071         IMPORT_C void GetModuleStatus(TPositionModuleStatus& aModuleStatus) const;
01072 
01073 protected:
01074         IMPORT_C virtual void DoReset(TInt aSizeOfClass);
01075 
01076 protected:
01078         TPositionModuleStatus iModuleStatus;
01079         };
01080 
01081 
01090 class TPositionUpdateOptionsBase : public TPositionClassTypeBase
01091         {
01092 protected:
01093         IMPORT_C TPositionUpdateOptionsBase();
01094         IMPORT_C TPositionUpdateOptionsBase(TTimeIntervalMicroSeconds aInterval,
01095                                             TTimeIntervalMicroSeconds aTimeOut = TTimeIntervalMicroSeconds(0),
01096                                             TTimeIntervalMicroSeconds aMaxAge = TTimeIntervalMicroSeconds(0));
01097 
01098 public:
01123         IMPORT_C void SetUpdateInterval(TTimeIntervalMicroSeconds aInterval);
01124 
01143         IMPORT_C void SetUpdateTimeOut(TTimeIntervalMicroSeconds aTimeOut);
01144 
01160         IMPORT_C void SetMaxUpdateAge(TTimeIntervalMicroSeconds aMaxAge);
01161 
01171         IMPORT_C TTimeIntervalMicroSeconds UpdateInterval() const;
01172 
01182         IMPORT_C TTimeIntervalMicroSeconds UpdateTimeOut() const;
01183 
01193         IMPORT_C TTimeIntervalMicroSeconds MaxUpdateAge() const;
01194 
01195 protected:
01197         TTimeIntervalMicroSeconds iUpdateInterval;
01199         TTimeIntervalMicroSeconds iUpdateTimeOut;
01201         TTimeIntervalMicroSeconds iMaxUpdateAge;
01202 
01203 private:
01205         TUint8 iReserved[8];
01206         };
01207 
01211 class TPositionUpdateOptions : public TPositionUpdateOptionsBase
01212         {
01213 public:
01214 
01218         IMPORT_C TPositionUpdateOptions();
01219 
01246         IMPORT_C TPositionUpdateOptions(TTimeIntervalMicroSeconds aInterval,
01247                                         TTimeIntervalMicroSeconds aTimeOut = TTimeIntervalMicroSeconds(0),
01248                                         TTimeIntervalMicroSeconds aMaxAge = TTimeIntervalMicroSeconds(0),
01249                                         TBool aAcceptPartialUpdates = EFalse);
01250 
01265         IMPORT_C void SetAcceptPartialUpdates(TBool aAcceptPartialUpdates);
01266 
01277         IMPORT_C TBool AcceptPartialUpdates() const;
01278 
01279 protected:
01281         TBool iAcceptPartialUpdates;
01282 
01283 private:
01285         TUint8 iReserved[16];
01286         };
01287 
01288 
01289 //__LBSCOMMON_H__
01290 #endif

Copyright © Nokia Corporation 2001-2008
Back to top