First public contribution.
1 // Copyright (c) 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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // streammap.h: defines COpenWfcStreamMap
22 #include <e32std.h> //for RFastLock
23 #include <e32hashtab.h> //for RHashMap
27 class MSurfaceUpdateServerProvider;
28 class CExtensionContainer;
29 class RSurfaceManager;
31 NONSHARABLE_CLASS(COpenWfcStreamMap): public CBase
35 * Returns a reference to the singleton instance.
37 * @return The pointer to the singleton instance
39 IMPORT_C static COpenWfcStreamMap& InstanceL();
41 * Look up a specified TSurfaceId key in the associative array and return a pointer to the
42 * corresponding to a native stream. The reference counter of the native stream is incremented by one.
44 * @param aSurfaceId The TSurfaceId key to look up
45 * @return A pointer to the corresponding native stream, if the specified TSurfacId was found
46 * NULL if the look up did not succeed
48 CSurfaceStream* Find(const TSurfaceId& aSurfaceId);
50 * Look up a specified TSurfaceId key in the associative array and return a pointer to the
51 * corresponding to a native stream. The reference of the native stream is incremented by one.
52 * If no native stream is found a new native stream instance is created.
54 * @param aSurfaceId The TSurfaceId key to look up
55 * @return A pointer to the corresponding native stream, if the specified TSurfacId was found
56 * NULL if the look up did not succeed
58 CSurfaceStream* AcquireL(const TSurfaceId& aSurfaceId);
60 * Query the number of elements stored in the stream hash map.
62 * @return The number of the key-value pairs stored
64 IMPORT_C TInt Count();
69 * Register a screen number for surface update notifications.
71 * @param aScreenNum The screen for which we enable the notification mechanism
72 * @param aPriority The priority associated with the screen
73 * @param aPriority The internal version
74 * @return KErrNone if operation is completed successfully
76 TInt RegisterScreenNotifications(TInt aScreenNum, TInt aPriority,TInt aInternalVersion);
79 * Retieves the screen updater associate with the specified screen
81 * @param aScreenNum The screen number
82 * @return Pointer to screen updater id successful or NULL otherwise
84 CExtensionContainer* RegisteredScreenNotifications(TInt aScreenNum);
87 * Unregister the screen updater
89 * @param aScreenNum The screen number
90 * @return KErrNone if operation is completed successfully
92 TInt UnregisterScreenNotifications(TInt aScreenNum);
95 * Returns a reference to the surface manager.
97 * @return A reference to the local SurfaceManager
99 IMPORT_C RSurfaceManager& SurfaceManager();
102 * Returns a pointer to the main heap
104 * @return A pointer to the main heap
106 IMPORT_C RHeap* GetMainHeap();
114 friend class CSurfaceStream;
116 * Destroys the specified native stream IF the native stream reference counter is zero.
117 * The counter reference of the native stream is tested prior its destruction and
118 * if positive the destruction will not happen
120 * @param aStream The stream to be destroyed
121 * @return KErrNone if the native stream is removed
122 * KErrArgument if the parameter is invalid
123 * KErrInUse if the stream has a owner
124 * KErrNotFound if the TSurfaceId key was not found
126 TInt LockDestroy(CSurfaceStream* aStream);
134 ~COpenWfcStreamMap();
137 * Auxilliary private class to insure the release of a lock
142 Guard(RFastLock& aLock);
149 * Symbian constructor used with two stage construction pattern
153 Forms a 32-bit hash value from a TSurfaceId.
155 @param aHashKey The 64-bit key to be hashed.
156 @return 32-bit hash value.
158 static TUint32 HashFunction(const TSurfaceId& aHashKey);
160 static TInt COpenWfcStreamMap::DeleteSingleton(TAny* aData);
163 * Mutex used for controlling the access to the native streams map
169 RHashMap<TSurfaceId, CSurfaceStream*> iMap;
171 * Initial HashMap size
173 static const TInt iInitialSize = 0;
175 * Singleton instance placeholder
177 static COpenWfcStreamMap* pInstance;
181 RSurfaceManager* iSurfaceManager;
183 RHeap *iMainHeap; //< --This points to main thread's heap--
185 RHashMap<TInt32, CExtensionContainer*> iRegisteredUpdaters; //< Proxy objects for handing surface update notifications.
187 MSurfaceUpdateServerProvider* iSurfUpdateServ; // Pointer to the surface update server
190 #endif /* STREAMMAP_H */