|
1 /* |
|
2 * Copyright (c) 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 #ifndef CPOSCONTROLLERMANAGER_H |
|
20 #define CPOSCONTROLLERMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32hashtab.h> |
|
24 #include <lbspositioninfo.h> |
|
25 |
|
26 class CPosControllerBase; |
|
27 class CPosSimulationPositioner; |
|
28 |
|
29 /** |
|
30 * Singleton class that manages positioning controllers |
|
31 */ |
|
32 NONSHARABLE_CLASS( CPosControllerManager ) : public CBase |
|
33 { |
|
34 public: |
|
35 /** |
|
36 * Returns the singleton instance. Each call to InstanceL() |
|
37 * should be matched witch a call to ReleaseInstance() |
|
38 * @return Instance of class CPosControllerManager |
|
39 * @leave System wide error code |
|
40 */ |
|
41 static CPosControllerManager* InstanceL(); |
|
42 /** |
|
43 * Releases the singleton instance. |
|
44 * @param aSimPos CPosSimulationPositioner which releases manager |
|
45 */ |
|
46 void ReleaseInstance(const CPosSimulationPositioner& aSimPos); |
|
47 /** |
|
48 * Gets or creates new controller for given CPosSimulationPositioner |
|
49 * @param aSimPos CPosSimulationPositioner which requesting for controller |
|
50 * @return CPosControllerBase instance. Be careful the owner of this instance |
|
51 * is still CPosControllerManager. To prevent memory leaks you have to call |
|
52 * ReleaseInstance(CPosSimulationPositioner&) function when You finish using controller. |
|
53 */ |
|
54 CPosControllerBase& ControllerL(const CPosSimulationPositioner& aSimPos); |
|
55 /** |
|
56 * Returns iLastFix |
|
57 * @return iLastFix |
|
58 */ |
|
59 TPositionInfo& GetLastFix(); |
|
60 /** |
|
61 * Sets value of iLastFix |
|
62 * @param aPosInfo Position info which will set iLastFix |
|
63 */ |
|
64 void SetLastFix(TPositionInfo& aPosInfo); |
|
65 /** |
|
66 * Returns iLastFixIsPartial |
|
67 * @return iLastFixIsPartial |
|
68 */ |
|
69 TBool GetLastFixIsPartial(); |
|
70 /** |
|
71 * Sets value of iLastFixIsPartial |
|
72 * @param aPartial defines value to which iLastFixIsPartial will be set |
|
73 */ |
|
74 void SetLastFixIsPartial(TBool aPartial); |
|
75 |
|
76 private: |
|
77 CPosControllerManager(); |
|
78 virtual ~CPosControllerManager(); |
|
79 void ConstructL(); |
|
80 CPosControllerBase* CreateControllerL(const CPosSimulationPositioner& aSimPos); |
|
81 TBool RepositoryTrpValueL(); |
|
82 |
|
83 private: |
|
84 /** |
|
85 * Amount of references to the singleton instance. |
|
86 * Instance will be deleted when count reaches zero. |
|
87 */ |
|
88 TUint iReferenceCount; |
|
89 /** |
|
90 * Pointer to single controller object which will be used |
|
91 * by all positioners. Works only when central repository key |
|
92 * time relative playback is on. |
|
93 */ |
|
94 CPosControllerBase* iTrpController; |
|
95 /** |
|
96 * Map between positioners and controllers. |
|
97 * This array is used for proper creation and deletion of controllers. |
|
98 */ |
|
99 RPtrHashMap<CPosSimulationPositioner, CPosControllerBase> iPositionerControllerMap; |
|
100 /** |
|
101 * Defines if time relative playback is on or off. |
|
102 */ |
|
103 TBool iTrp; |
|
104 /** |
|
105 * Stores last valid fix, |
|
106 */ |
|
107 TPositionInfo iLastFix; |
|
108 /** |
|
109 * Indicates if last valid fix was partial |
|
110 */ |
|
111 TBool iLastFixIsPartial; |
|
112 |
|
113 }; |
|
114 |
|
115 #endif //CPOSCONTROLLERMANAGER_H |