|
1 /* |
|
2 * Copyright (c) 2007-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 CPOSSINGLETONMANAGER_H |
|
21 #define CPOSSINGLETONMANAGER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 // Singleton object ID. |
|
26 enum { |
|
27 EPosSigletonObjectIdPsyFixStateManager = 1, |
|
28 EPosSigletonObjectIdPsyListHandlerId = 2, |
|
29 EPosSigletonObjectConstManagerId = 3, |
|
30 EPosSigletonObjectExtGpsMonitorId = 4 |
|
31 }; |
|
32 |
|
33 |
|
34 /** |
|
35 * The CPosSingletonManager manages all singleton objects of default proxy. |
|
36 * Each singleton object must have a unique ID. This ID is not allocated |
|
37 * by this class. The singleton class itself must guarentee that the ID |
|
38 * is unique within the DLL. |
|
39 * |
|
40 * Usage: |
|
41 * |
|
42 * @code |
|
43 * @endcode |
|
44 */ |
|
45 class CPosSingletonManager : public CBase |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 ~CPosSingletonManager(); |
|
53 |
|
54 public: // Functions from base classes |
|
55 /** |
|
56 * Get the singleton object. This function |
|
57 * returns NULL if the object is not set before. |
|
58 * |
|
59 * @param aObjectId The ID of the singleton object. |
|
60 * @return The pointer to the singleton ojbect. NULL |
|
61 * if the object has not been set. |
|
62 */ |
|
63 static CBase* GetObject( TInt aObjectId ); |
|
64 |
|
65 /** |
|
66 * Set the singleton object. This function |
|
67 * panics in debug mode if the object has been set. |
|
68 * |
|
69 * @param aObject The pointer to the object. NULL will |
|
70 * clear the object. |
|
71 * @param aObjectId The id of the object. |
|
72 */ |
|
73 static void SetObjectL( |
|
74 CBase* aObject, |
|
75 TInt aObjectId ); |
|
76 |
|
77 /** |
|
78 * Release the singleton object. |
|
79 * |
|
80 * @param aObjectId The id of the object. |
|
81 */ |
|
82 static void ReleaseObject( |
|
83 TInt aObjectId ); |
|
84 |
|
85 private: |
|
86 /** |
|
87 * Get instance of singleton manager. |
|
88 */ |
|
89 static CPosSingletonManager* GetInstanceL(); |
|
90 |
|
91 /** |
|
92 * Get instance of the singleton manager. This function |
|
93 * returns NULL if the singleton manager has not be |
|
94 * constructed. |
|
95 */ |
|
96 static CPosSingletonManager* GetInstance(); |
|
97 |
|
98 /** |
|
99 * C++ default constructor. |
|
100 */ |
|
101 CPosSingletonManager(); |
|
102 |
|
103 /** |
|
104 * Get a object |
|
105 */ |
|
106 CBase* GetAObject( TInt aObjectId ); |
|
107 |
|
108 /** |
|
109 * Release a object |
|
110 */ |
|
111 void ReleaseAObject( TInt aObjectId ); |
|
112 |
|
113 /** |
|
114 * Set a object |
|
115 */ |
|
116 void SetAObjectL( |
|
117 CBase* aObject, |
|
118 TInt aObjectId ); |
|
119 |
|
120 /** |
|
121 * Check if the singleton manager object shall be cleard. |
|
122 * When there is no sigleton object stored, then this object |
|
123 * shall be cleared |
|
124 */ |
|
125 void ClearIfNeeded(); |
|
126 |
|
127 // By default, prohibit copy constructor |
|
128 CPosSingletonManager(const CPosSingletonManager&); |
|
129 // Prohibit assigment operator |
|
130 CPosSingletonManager& operator= (const CPosSingletonManager&); |
|
131 |
|
132 private: // Data |
|
133 //Struct defination for singleton object |
|
134 struct TSingletonOb |
|
135 { |
|
136 CBase* iObject; |
|
137 TInt iObjectId; |
|
138 }; |
|
139 |
|
140 //Objects array |
|
141 RArray< TSingletonOb > iObjectsArray; |
|
142 }; |
|
143 |
|
144 #endif // CPOSSINGLETONMANAGER_H |
|
145 |
|
146 // End of File |