sl@0
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// streammap.h: defines COpenWfcStreamMap
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef STREAMMAP_H
|
sl@0
|
19 |
#define STREAMMAP_H
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <e32std.h> //for RFastLock
|
sl@0
|
23 |
#include <e32hashtab.h> //for RHashMap
|
sl@0
|
24 |
|
sl@0
|
25 |
class CSurfaceStream;
|
sl@0
|
26 |
class TSurfaceId;
|
sl@0
|
27 |
class MSurfaceUpdateServerProvider;
|
sl@0
|
28 |
class CExtensionContainer;
|
sl@0
|
29 |
class RSurfaceManager;
|
sl@0
|
30 |
|
sl@0
|
31 |
NONSHARABLE_CLASS(COpenWfcStreamMap): public CBase
|
sl@0
|
32 |
{
|
sl@0
|
33 |
public:
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
* Returns a reference to the singleton instance.
|
sl@0
|
36 |
*
|
sl@0
|
37 |
* @return The pointer to the singleton instance
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
IMPORT_C static COpenWfcStreamMap& InstanceL();
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
* Look up a specified TSurfaceId key in the associative array and return a pointer to the
|
sl@0
|
42 |
* corresponding to a native stream. The reference counter of the native stream is incremented by one.
|
sl@0
|
43 |
*
|
sl@0
|
44 |
* @param aSurfaceId The TSurfaceId key to look up
|
sl@0
|
45 |
* @return A pointer to the corresponding native stream, if the specified TSurfacId was found
|
sl@0
|
46 |
* NULL if the look up did not succeed
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
CSurfaceStream* Find(const TSurfaceId& aSurfaceId);
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
* Look up a specified TSurfaceId key in the associative array and return a pointer to the
|
sl@0
|
51 |
* corresponding to a native stream. The reference of the native stream is incremented by one.
|
sl@0
|
52 |
* If no native stream is found a new native stream instance is created.
|
sl@0
|
53 |
*
|
sl@0
|
54 |
* @param aSurfaceId The TSurfaceId key to look up
|
sl@0
|
55 |
* @return A pointer to the corresponding native stream, if the specified TSurfacId was found
|
sl@0
|
56 |
* NULL if the look up did not succeed
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
CSurfaceStream* AcquireL(const TSurfaceId& aSurfaceId);
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
* Query the number of elements stored in the stream hash map.
|
sl@0
|
61 |
*
|
sl@0
|
62 |
* @return The number of the key-value pairs stored
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
IMPORT_C TInt Count();
|
sl@0
|
65 |
|
sl@0
|
66 |
public:
|
sl@0
|
67 |
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
* Register a screen number for surface update notifications.
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* @param aScreenNum The screen for which we enable the notification mechanism
|
sl@0
|
72 |
* @param aPriority The priority associated with the screen
|
sl@0
|
73 |
* @param aPriority The internal version
|
sl@0
|
74 |
* @return KErrNone if operation is completed successfully
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
TInt RegisterScreenNotifications(TInt aScreenNum, TInt aPriority,TInt aInternalVersion);
|
sl@0
|
77 |
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
* Retieves the screen updater associate with the specified screen
|
sl@0
|
80 |
*
|
sl@0
|
81 |
* @param aScreenNum The screen number
|
sl@0
|
82 |
* @return Pointer to screen updater id successful or NULL otherwise
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
CExtensionContainer* RegisteredScreenNotifications(TInt aScreenNum);
|
sl@0
|
85 |
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
* Unregister the screen updater
|
sl@0
|
88 |
*
|
sl@0
|
89 |
* @param aScreenNum The screen number
|
sl@0
|
90 |
* @return KErrNone if operation is completed successfully
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
TInt UnregisterScreenNotifications(TInt aScreenNum);
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
* Returns a reference to the surface manager.
|
sl@0
|
96 |
*
|
sl@0
|
97 |
* @return A reference to the local SurfaceManager
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
IMPORT_C RSurfaceManager& SurfaceManager();
|
sl@0
|
100 |
|
sl@0
|
101 |
/**
|
sl@0
|
102 |
* Returns a pointer to the main heap
|
sl@0
|
103 |
*
|
sl@0
|
104 |
* @return A pointer to the main heap
|
sl@0
|
105 |
*/
|
sl@0
|
106 |
IMPORT_C RHeap* GetMainHeap();
|
sl@0
|
107 |
|
sl@0
|
108 |
/**
|
sl@0
|
109 |
* Sets the main heap
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
void SetMainHeap();
|
sl@0
|
112 |
|
sl@0
|
113 |
protected:
|
sl@0
|
114 |
friend class CSurfaceStream;
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
* Destroys the specified native stream IF the native stream reference counter is zero.
|
sl@0
|
117 |
* The counter reference of the native stream is tested prior its destruction and
|
sl@0
|
118 |
* if positive the destruction will not happen
|
sl@0
|
119 |
*
|
sl@0
|
120 |
* @param aStream The stream to be destroyed
|
sl@0
|
121 |
* @return KErrNone if the native stream is removed
|
sl@0
|
122 |
* KErrArgument if the parameter is invalid
|
sl@0
|
123 |
* KErrInUse if the stream has a owner
|
sl@0
|
124 |
* KErrNotFound if the TSurfaceId key was not found
|
sl@0
|
125 |
*/
|
sl@0
|
126 |
TInt LockDestroy(CSurfaceStream* aStream);
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
* Constructor
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
COpenWfcStreamMap();
|
sl@0
|
131 |
/**
|
sl@0
|
132 |
* Destructor.
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
~COpenWfcStreamMap();
|
sl@0
|
135 |
private:
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
* Auxilliary private class to insure the release of a lock
|
sl@0
|
138 |
*/
|
sl@0
|
139 |
class Guard
|
sl@0
|
140 |
{
|
sl@0
|
141 |
public:
|
sl@0
|
142 |
Guard(RFastLock& aLock);
|
sl@0
|
143 |
~Guard();
|
sl@0
|
144 |
private:
|
sl@0
|
145 |
RFastLock& iLock;
|
sl@0
|
146 |
};
|
sl@0
|
147 |
private:
|
sl@0
|
148 |
/**
|
sl@0
|
149 |
* Symbian constructor used with two stage construction pattern
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
void ConstructL();
|
sl@0
|
152 |
/**
|
sl@0
|
153 |
Forms a 32-bit hash value from a TSurfaceId.
|
sl@0
|
154 |
|
sl@0
|
155 |
@param aHashKey The 64-bit key to be hashed.
|
sl@0
|
156 |
@return 32-bit hash value.
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
static TUint32 HashFunction(const TSurfaceId& aHashKey);
|
sl@0
|
159 |
|
sl@0
|
160 |
static TInt COpenWfcStreamMap::DeleteSingleton(TAny* aData);
|
sl@0
|
161 |
private:
|
sl@0
|
162 |
/**
|
sl@0
|
163 |
* Mutex used for controlling the access to the native streams map
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
RFastLock iMutex;
|
sl@0
|
166 |
/**
|
sl@0
|
167 |
* Native stream map
|
sl@0
|
168 |
*/
|
sl@0
|
169 |
RHashMap<TSurfaceId, CSurfaceStream*> iMap;
|
sl@0
|
170 |
/**
|
sl@0
|
171 |
* Initial HashMap size
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
static const TInt iInitialSize = 0;
|
sl@0
|
174 |
/**
|
sl@0
|
175 |
* Singleton instance placeholder
|
sl@0
|
176 |
*/
|
sl@0
|
177 |
static COpenWfcStreamMap* pInstance;
|
sl@0
|
178 |
/**
|
sl@0
|
179 |
* Surface manager
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
RSurfaceManager* iSurfaceManager;
|
sl@0
|
182 |
|
sl@0
|
183 |
RHeap *iMainHeap; //< --This points to main thread's heap--
|
sl@0
|
184 |
|
sl@0
|
185 |
RHashMap<TInt32, CExtensionContainer*> iRegisteredUpdaters; //< Proxy objects for handing surface update notifications.
|
sl@0
|
186 |
|
sl@0
|
187 |
MSurfaceUpdateServerProvider* iSurfUpdateServ; // Pointer to the surface update server
|
sl@0
|
188 |
};
|
sl@0
|
189 |
|
sl@0
|
190 |
#endif /* STREAMMAP_H */
|