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