sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // streammap.h: defines COpenWfcStreamMap sl@0: // sl@0: // sl@0: sl@0: #ifndef STREAMMAP_H sl@0: #define STREAMMAP_H sl@0: sl@0: #include sl@0: #include //for RFastLock sl@0: #include //for RHashMap sl@0: sl@0: class CSurfaceStream; sl@0: class TSurfaceId; sl@0: class MSurfaceUpdateServerProvider; sl@0: class CExtensionContainer; sl@0: class RSurfaceManager; sl@0: sl@0: NONSHARABLE_CLASS(COpenWfcStreamMap): public CBase sl@0: { sl@0: public: sl@0: /** sl@0: * Returns a reference to the singleton instance. sl@0: * sl@0: * @return The pointer to the singleton instance sl@0: */ sl@0: IMPORT_C static COpenWfcStreamMap& InstanceL(); sl@0: /** sl@0: * Look up a specified TSurfaceId key in the associative array and return a pointer to the sl@0: * corresponding to a native stream. The reference counter of the native stream is incremented by one. sl@0: * sl@0: * @param aSurfaceId The TSurfaceId key to look up sl@0: * @return A pointer to the corresponding native stream, if the specified TSurfacId was found sl@0: * NULL if the look up did not succeed sl@0: */ sl@0: CSurfaceStream* Find(const TSurfaceId& aSurfaceId); sl@0: /** sl@0: * Look up a specified TSurfaceId key in the associative array and return a pointer to the sl@0: * corresponding to a native stream. The reference of the native stream is incremented by one. sl@0: * If no native stream is found a new native stream instance is created. sl@0: * sl@0: * @param aSurfaceId The TSurfaceId key to look up sl@0: * @return A pointer to the corresponding native stream, if the specified TSurfacId was found sl@0: * NULL if the look up did not succeed sl@0: */ sl@0: CSurfaceStream* AcquireL(const TSurfaceId& aSurfaceId); sl@0: /** sl@0: * Query the number of elements stored in the stream hash map. sl@0: * sl@0: * @return The number of the key-value pairs stored sl@0: */ sl@0: IMPORT_C TInt Count(); sl@0: sl@0: public: sl@0: sl@0: /** sl@0: * Register a screen number for surface update notifications. sl@0: * sl@0: * @param aScreenNum The screen for which we enable the notification mechanism sl@0: * @param aPriority The priority associated with the screen sl@0: * @param aPriority The internal version sl@0: * @return KErrNone if operation is completed successfully sl@0: */ sl@0: TInt RegisterScreenNotifications(TInt aScreenNum, TInt aPriority,TInt aInternalVersion); sl@0: sl@0: /** sl@0: * Retieves the screen updater associate with the specified screen sl@0: * sl@0: * @param aScreenNum The screen number sl@0: * @return Pointer to screen updater id successful or NULL otherwise sl@0: */ sl@0: CExtensionContainer* RegisteredScreenNotifications(TInt aScreenNum); sl@0: sl@0: /** sl@0: * Unregister the screen updater sl@0: * sl@0: * @param aScreenNum The screen number sl@0: * @return KErrNone if operation is completed successfully sl@0: */ sl@0: TInt UnregisterScreenNotifications(TInt aScreenNum); sl@0: sl@0: /** sl@0: * Returns a reference to the surface manager. sl@0: * sl@0: * @return A reference to the local SurfaceManager sl@0: */ sl@0: IMPORT_C RSurfaceManager& SurfaceManager(); sl@0: sl@0: /** sl@0: * Returns a pointer to the main heap sl@0: * sl@0: * @return A pointer to the main heap sl@0: */ sl@0: IMPORT_C RHeap* GetMainHeap(); sl@0: sl@0: /** sl@0: * Sets the main heap sl@0: */ sl@0: void SetMainHeap(); sl@0: sl@0: protected: sl@0: friend class CSurfaceStream; sl@0: /** sl@0: * Destroys the specified native stream IF the native stream reference counter is zero. sl@0: * The counter reference of the native stream is tested prior its destruction and sl@0: * if positive the destruction will not happen sl@0: * sl@0: * @param aStream The stream to be destroyed sl@0: * @return KErrNone if the native stream is removed sl@0: * KErrArgument if the parameter is invalid sl@0: * KErrInUse if the stream has a owner sl@0: * KErrNotFound if the TSurfaceId key was not found sl@0: */ sl@0: TInt LockDestroy(CSurfaceStream* aStream); sl@0: /** sl@0: * Constructor sl@0: */ sl@0: COpenWfcStreamMap(); sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~COpenWfcStreamMap(); sl@0: private: sl@0: /** sl@0: * Auxilliary private class to insure the release of a lock sl@0: */ sl@0: class Guard sl@0: { sl@0: public: sl@0: Guard(RFastLock& aLock); sl@0: ~Guard(); sl@0: private: sl@0: RFastLock& iLock; sl@0: }; sl@0: private: sl@0: /** sl@0: * Symbian constructor used with two stage construction pattern sl@0: */ sl@0: void ConstructL(); sl@0: /** sl@0: Forms a 32-bit hash value from a TSurfaceId. sl@0: sl@0: @param aHashKey The 64-bit key to be hashed. sl@0: @return 32-bit hash value. sl@0: */ sl@0: static TUint32 HashFunction(const TSurfaceId& aHashKey); sl@0: sl@0: static TInt COpenWfcStreamMap::DeleteSingleton(TAny* aData); sl@0: private: sl@0: /** sl@0: * Mutex used for controlling the access to the native streams map sl@0: */ sl@0: RFastLock iMutex; sl@0: /** sl@0: * Native stream map sl@0: */ sl@0: RHashMap iMap; sl@0: /** sl@0: * Initial HashMap size sl@0: */ sl@0: static const TInt iInitialSize = 0; sl@0: /** sl@0: * Singleton instance placeholder sl@0: */ sl@0: static COpenWfcStreamMap* pInstance; sl@0: /** sl@0: * Surface manager sl@0: */ sl@0: RSurfaceManager* iSurfaceManager; sl@0: sl@0: RHeap *iMainHeap; //< --This points to main thread's heap-- sl@0: sl@0: RHashMap iRegisteredUpdaters; //< Proxy objects for handing surface update notifications. sl@0: sl@0: MSurfaceUpdateServerProvider* iSurfUpdateServ; // Pointer to the surface update server sl@0: }; sl@0: sl@0: #endif /* STREAMMAP_H */