os/mm/mmresourcemgmt/mmresctrl/inc/mmrcserverinfo.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmresourcemgmt/mmresctrl/inc/mmrcserverinfo.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,275 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef MMRCSERVERINFO_H__
    1.20 +#define MMRCSERVERINFO_H__
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <e32msgqueue.h>
    1.24 +#include "mmrcutil.h"
    1.25 +#include "mmrcclientserver.h"
    1.26 +#include "mmrcserversession.h" 
    1.27 +
    1.28 +class CMMRCServerController;
    1.29 +
    1.30 +/**
    1.31 +@internalComponent
    1.32 +
    1.33 +This class implements the MMRC Server Info. 
    1.34 +The main purpose of this class is to contain the different information
    1.35 +  about the MMRC Server.
    1.36 +  The server state
    1.37 +  The queue of resource Context
    1.38 +  The queue of resource in process
    1.39 +*/	
    1.40 +NONSHARABLE_CLASS( CMMRCServerInfo ): public CBase
    1.41 +	{
    1.42 +	typedef RMMRCFifoQueue<CMMRCServerSession> RMMRCContextsQueueTD;
    1.43 +	typedef RMMRCFifoOrderQueue<CMMRCServerSession> RMMRCContextsQueueOrderTD;
    1.44 +
    1.45 +public:
    1.46 +	/**
    1.47 +	 * Constructs, and returns a pointer to, a new CMMRCServerInfo object.
    1.48 +	 * Leaves on failure.
    1.49 +	 * @param CMMRCServerController& A reference on the MMRC Server controller
    1.50 +	 * @return CMMRCServerInfo* A pointer to newly created utlitly object.
    1.51 +	 */	
    1.52 +	static CMMRCServerInfo* NewL(CMMRCServerController& aServerController); 
    1.53 +	
    1.54 +	/**
    1.55 +	 * Constructs, leaves object on the cleanup stack, and returns a pointer
    1.56 +	 * to, a new CMMRCServerInfo object.
    1.57 +	 * Leaves on failure.
    1.58 +	 * @param CMMRCServerController& A reference on the MMRC Server controller
    1.59 +	 * @return CMMRCServerInfo* A pointer to newly created utlitly object.
    1.60 +	 */	
    1.61 +	 static CMMRCServerInfo* NewLC(CMMRCServerController& aServerController);
    1.62 + 	
    1.63 +	/**
    1.64 +	 * Destructor.
    1.65 +	 */
    1.66 +	~CMMRCServerInfo();
    1.67 +
    1.68 +public:
    1.69 +
    1.70 +	TInt AllocatedPausedContextsCount();
    1.71 +	TInt RequestsCount();
    1.72 +	TInt AllocatedResourceContextsCount();
    1.73 +	TInt AllocatedAPRContextsCount();
    1.74 +
    1.75 +
    1.76 +	/** 
    1.77 +	 * Change the state of the server
    1.78 +	 * @param TMMRCServerState aNewState
    1.79 +	 * @param TUint64 aContextId
    1.80 +	 */
    1.81 +	void SwitchServerState(TMMRCServerState aNewState, TUint64 aContextId);
    1.82 +	
    1.83 +	
    1.84 +	/** 
    1.85 +	 * get the state of the server
    1.86 +	 * @param TMMRCServerState the state of the server
    1.87 +	 * @param TUint64 aContextId
    1.88 +	 */
    1.89 +	void ServerState(TMMRCServerState& aServerState, TUint64& aContextId) const;
    1.90 +	
    1.91 +	/** 
    1.92 +	 * Push a Context on the Context queue
    1.93 +	 * @param CMMRCServerSession& aServerSession
    1.94 +	 * @leave in case of memory error
    1.95 +	 */
    1.96 +	void PushRequestL(const CMMRCServerSession& aServerSession);
    1.97 +	
    1.98 +	/** 
    1.99 +	 * Pop and remove the first Context from the Context queue
   1.100 +	 * @return CMMRCServerSession* the session of the Context
   1.101 +	 */
   1.102 +	CMMRCServerSession* PopAndRemoveFirstRequest();
   1.103 +	
   1.104 +	/** 
   1.105 +	 * Pop and remove the first Context from the Context queue by contextId
   1.106 +	 * @param const TAudioContextId& aContextId
   1.107 +	 * @return CMMRCServerSession* the session of the Context
   1.108 +	 */
   1.109 +	CMMRCServerSession* PopAndRemoveFirstRequestByContextId( const TAudioContextId& aContextId );
   1.110 +
   1.111 +	/** 
   1.112 +	 * Pop and remove the first Context of the highest priority from the Context queue
   1.113 +	 * @param TInt aPriority
   1.114 +	 * @return CMMRCServerSession* the session of the Context
   1.115 +	 */
   1.116 +	CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( );
   1.117 +
   1.118 +	/** 
   1.119 +	 * Pop and remove the first Context of the highest priority and more than aPriority 
   1.120 +	 * from the Context queue
   1.121 +	 * @param TInt aPriority
   1.122 +	 * @return CMMRCServerSession* the session of the Context
   1.123 +	 */
   1.124 +	CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( TInt aPriority );
   1.125 +
   1.126 +	/** 
   1.127 +	 * Pop the first Context from the Context queue
   1.128 +	 * @return CMMRCServerSession* the session of the Context
   1.129 +	 */
   1.130 +	CMMRCServerSession* PopFirstRequest( ) const;
   1.131 +
   1.132 +	/** 
   1.133 +	 * Pop the first Context of the highest priority from the Context queue
   1.134 +	 * @return CMMRCServerSession* the session of the Context
   1.135 +	 */
   1.136 +	CMMRCServerSession* PopRequestFirstHighestPriority( ) const;
   1.137 +
   1.138 +	/** 
   1.139 +	 * Pop the first Context of the highest priority and more than aPriority 
   1.140 +	 * from the Context queue
   1.141 +	 * @param TInt aPriority
   1.142 +	 * @return CMMRCServerSession* the session of the Context
   1.143 +	 */
   1.144 +	CMMRCServerSession* PopRequestFirstHighestPriority( TInt aPriority ) const;
   1.145 +
   1.146 +	/** 
   1.147 +	 * Push an Context on the in-process Context queue
   1.148 +	 * @param CMMRCServerSession& aServerSession
   1.149 +	 * @leave in case of memory error
   1.150 +	 */
   1.151 +	void PushAllocatedResourceContextL(const CMMRCServerSession& aServerSession);
   1.152 +	
   1.153 +	/** 
   1.154 +	 * Pop and remove the first Context of the highest priority from the in-process Context queue
   1.155 +	 * @return CMMRCServerSession* the session of the Context
   1.156 +	 */
   1.157 +	CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContext();
   1.158 +	
   1.159 +	/** 
   1.160 +	 * Pop and remove the first Context from the in-process Context queue by contextId
   1.161 +	 * @param const TAudioContextId& aContextId
   1.162 +	 * @return CMMRCServerSession* the session of the Context
   1.163 +	 */
   1.164 +	CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContextByContextId( const TAudioContextId& aContextId );
   1.165 +
   1.166 +
   1.167 +	/** 
   1.168 +	 * Pop the first Context from the in-process Context queue
   1.169 +	 * @return CMMRCServerSession* the session of the Context
   1.170 +	 */
   1.171 +	CMMRCServerSession* PopFirstAllocatedResourceContext( ) const;
   1.172 +
   1.173 +	void PushPausedContextL(const CMMRCServerSession& aServerSession );
   1.174 +	CMMRCServerSession* PopAndRemoveFirstPausedContext();
   1.175 +	CMMRCServerSession* PopAndRemovePausedContext(const TAudioContextId& aContextId );
   1.176 +	CMMRCServerSession* PausedContextByIndex(TInt aIndex);
   1.177 +	
   1.178 +	void PushAPRContextL(const CMMRCServerSession& aServerSession );
   1.179 +	CMMRCServerSession* PopAndRemoveFirstAPRContext();
   1.180 +	CMMRCServerSession* PopAndRemoveFirstAPRContextByContextId(const TAudioContextId& aContextId );
   1.181 +	CMMRCServerSession* PopFirstAPRContext() const;
   1.182 +	
   1.183 +	TBool IsOnAPRList(TAudioContextId aId);
   1.184 +	TBool IsOnPauseList(TAudioContextId aId);
   1.185 +
   1.186 +
   1.187 +private:	
   1.188 +	/**
   1.189 +	 * Push an Context on the Context queue in parameter
   1.190 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.191 +	 * @param CMMRCServerSession& aServerSession
   1.192 +	 * @leave in case of memory error
   1.193 +	 */
   1.194 +	void PushContextL(RMMRCContextsQueueTD& aContextsQueue, const CMMRCServerSession& aServerSession);
   1.195 +	
   1.196 +	/**
   1.197 +	 * Pop and remove the first Context of the highest priority from the Context queue in parameter
   1.198 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.199 +	 * @return CMMRCServerSession* the session of the Context
   1.200 +	 */
   1.201 +	CMMRCServerSession* PopAndRemoveFirstContext(RMMRCContextsQueueTD& aContextsQueue);
   1.202 +	
   1.203 +	/**
   1.204 +	 * Pop and remove the first Context from the Context queue in parameter by contextId
   1.205 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.206 +	 * @param const TAudioContextId& aContextId
   1.207 +	 * @return CMMRCServerSession* the session of the Context
   1.208 +	 */
   1.209 +	CMMRCServerSession* PopAndRemoveFirstContextByContextId(RMMRCContextsQueueTD& aContextsQueue, const TAudioContextId& aContextId );
   1.210 +	
   1.211 +	/**
   1.212 +	 * Pop and remove the first Context of the highest priority from the Context queue in parameter
   1.213 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.214 +	 * @return CMMRCServerSession* the session of the Context
   1.215 +	 */
   1.216 +	CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue);
   1.217 +	
   1.218 +	/**
   1.219 +	 * Pop and remove the first Context of the highest priority and more than aPriority 
   1.220 +	 * from the Context queue in parameter
   1.221 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.222 +	 * @param TInt aPriority
   1.223 +	 * @return CMMRCServerSession* the session of the Context
   1.224 +	 */
   1.225 +	CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue, TInt aPriority );
   1.226 +	
   1.227 +	/**
   1.228 +	 * Pop the first Context from the Context queue in parameter
   1.229 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.230 +	 * @return CMMRCServerSession* the session of the Context
   1.231 +	 */
   1.232 +	CMMRCServerSession* PopFirstContext(const RMMRCContextsQueueTD& aContextsQueue) const;
   1.233 +
   1.234 +	/**
   1.235 +	 * Pop the first Context of the highest priority from the Context queue in parameter
   1.236 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.237 +	 * @return CMMRCServerSession* the session of the Context 
   1.238 +	 */
   1.239 +	CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue) const;
   1.240 +
   1.241 +	/**
   1.242 +	 * Pop the first Context of the highest priority and more than aPriority 
   1.243 +	 * from the Context queue in parameter
   1.244 +	 * @param RMMRCContextsQueueTD& aContextsQueue
   1.245 +	 * @param TInt aPriority
   1.246 +	 * @return CMMRCServerSession* the session of the Context
   1.247 +	 */
   1.248 +	CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue, TInt aPriority ) const;
   1.249 +
   1.250 +	void PushContextInOrderL(RMMRCContextsQueueOrderTD& aContextsQueue, const CMMRCServerSession& aServerSession);
   1.251 +	CMMRCServerSession* PopAndRemoveFirstContextForPause(RMMRCContextsQueueOrderTD& aContextsQueue);
   1.252 +	CMMRCServerSession* PopAndRemoveContextIdForPause(RMMRCContextsQueueOrderTD& aContextsQueue, const TAudioContextId& aContextId );
   1.253 +	CMMRCServerSession* PausedContextByIndexForPause(RMMRCContextsQueueOrderTD& aContextsQueue, TInt aIndex);
   1.254 +
   1.255 +	
   1.256 +private:	
   1.257 +	/**
   1.258 +	 * By default Symbian 2nd phase constructor is private.
   1.259 +	 * @param CMMRCServerController& A reference on the MMRC Server controller
   1.260 +	 */
   1.261 +	CMMRCServerInfo(CMMRCServerController& aServerController);
   1.262 +	
   1.263 +	/**
   1.264 +	 * By default Symbian 2nd phase constructor is private.
   1.265 +	 */
   1.266 +	void ConstructL();
   1.267 +
   1.268 +private:
   1.269 +	CMMRCServerController& iMMRCServerController;
   1.270 +	TMMRCServerState iMMRCServerInfoState;
   1.271 +	RMMRCContextsQueueTD iMMRCContextsQueue; 					//0 or more context(s)
   1.272 +	RMMRCContextsQueueTD iMMRCAllocatedResourceContextsQueue; 
   1.273 +	RMMRCContextsQueueOrderTD iMMRCPausedContextsQueue;
   1.274 +	RMMRCContextsQueueTD iMMRCAPRContextsQueue;
   1.275 +	TUint64	iLastTransactionContextId;
   1.276 +	};
   1.277 +
   1.278 +#endif //__MMRCSERVERINFO_H__