sl@0: // Copyright (c) 2002-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: // sl@0: sl@0: #ifndef __LOGSERVOPERATIONQUEUE_H__ sl@0: #define __LOGSERVOPERATIONQUEUE_H__ sl@0: sl@0: #include sl@0: #include "LogServDefs.h" sl@0: #include "LogServShared.h" sl@0: #include "LogServOperationManager.h" sl@0: sl@0: // Classes referenced sl@0: class MLogServTaskInterface; sl@0: class CLogServOperationBase; sl@0: sl@0: /** sl@0: Implements the MLogServOperationManager interface. sl@0: The class maintains two queues of operations: sl@0: - "pending operations" queue. All pending operations are kept in here for execution; sl@0: - "completed operations" queue. If particular operation returns results for the client, that sl@0: operation will be moved to here after the execution; sl@0: CLogServOperationQueue implements MLogServOperationManager and dereives from CActive. sl@0: Every time when a new operation is added to the queue, CLogServOperationQueue object completes itsef sl@0: and schedules itself for an execution. When the active scheduler calls the RunL() method of the class, sl@0: an operation will be picked up from the pending queue and started. sl@0: sl@0: @see MLogServOperationManager sl@0: @see MLogServTaskInterface sl@0: @see CLogServOperationBase sl@0: sl@0: @internalComponent sl@0: */ sl@0: class CLogServOperationQueue : public CActive, public MLogServOperationManager sl@0: { sl@0: public: sl@0: static CLogServOperationQueue* NewL(MLogServTaskInterface& aTaskInterface, TInt aPriority); sl@0: ~CLogServOperationQueue(); sl@0: sl@0: private: sl@0: CLogServOperationQueue(MLogServTaskInterface& aTaskInterface, TInt aPriority); sl@0: sl@0: private: // From MLogServOperationManager sl@0: void OMOperationQueueAdd(CLogServOperationBase& aOperation); sl@0: void OMOperationQueueRemove(CLogServOperationBase& aOperation); sl@0: void OMGetResultL(TLogOperationId aId, TLogServSessionId aSessionId, const RMessage2& aMessageToWriteTo); sl@0: void OMCancel(TLogOperationId aId, TLogServSessionId aSessionId, TBool aCompleteRequest); sl@0: void OMCancel(TLogServSessionId aSessionId, TBool aCompleteRequest); sl@0: sl@0: private: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: private: // Internal methods sl@0: void CompleteRequest(TInt aCompletionCode = KErrNone); sl@0: void StartNextOpL(); sl@0: void DeleteFromQueue(TSglQue& aQueue, TLogOperationId aOperationId, TLogServSessionId aSessionId); sl@0: TBool QueueContainsOperation(TSglQue& aQueue, TLogOperationId aOperationId, TLogServSessionId aSessionId); sl@0: CLogServOperationBase* FindOperation(TSglQue& aQueue, TLogOperationId aOperationId, TLogServSessionId aSessionId); sl@0: sl@0: private: // Member data sl@0: sl@0: MLogServTaskInterface& iTaskInterface; sl@0: CLogServOperationBase* iCurrentOperation; sl@0: TSglQue iQueuePending; sl@0: TSglQue iQueueCompleted; sl@0: }; sl@0: sl@0: #endif