diff -r a2efdd544abf -r b47902b73a93 datasourceadaptation/gpsdatasourceadaptation/common/src/cpositionerq.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/datasourceadaptation/gpsdatasourceadaptation/common/src/cpositionerq.cpp Fri Jun 04 10:34:15 2010 +0100 @@ -0,0 +1,181 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @InternalComponent +*/ + +#include "psylogging.h" +#include "cpositionerq.h" +#include "psypanic.h" +#include "tpositionercall.h" + +/* +* CPositionerQ::NewL +* Two-phased constructor. +* @param aEnv pointer to the CPositionerEnvironment +*/ +CPositionerQ* CPositionerQ::NewL() + { + CPositionerQ* self = new( ELeave ) CPositionerQ(); + + return self; + } + +/* +* CPositionerQ::CPositionerQ +* C++ default constructor can NOT contain any code, that +* might leave. +*/ +CPositionerQ::CPositionerQ() + { + } + +/* +* CPositionerQ::~CPositionerQ +* Destructor. +*/ +CPositionerQ::~CPositionerQ() + { + __ASSERT_DEBUG(iPsyArray.Count() == 0, User::Panic(KAdaptationPanicCategory, EPanicQNotEmpty)); + + iPsyArray.Close(); + } + +/** +* Registers the PSY instance to the request handler +* @param aPSY pointer to the MPositioner +*/ +void CPositionerQ::RegisterPSYL(MPositioner* aPSY) + { + TRACESTRING("CPositionerQ::RegisterPSYL start...") + + //Register the psy + User::LeaveIfError(iPsyArray.Append(aPSY)); + + TRACESTRING("CPositionerQ::RegisterPSYL end") + } + +/** +* Unregisters the MPositioner instance +* @param aPSY pointer to the MPositioner +*/ +void CPositionerQ::UnregisterPSY(MPositioner* aPSY) + { + TRACESTRING("CPositionerQ::UnregisterPSY start...") + + TInt index = KErrNotFound; + index = Index(*aPSY); + + if(index!=KErrNotFound) + { + iPsyArray.Remove(index); + } + + TRACESTRING("CPositionerQ::UnregisterPSY end") + } + +/** +* Calles aCall::Call for all MPositioners in the queue +* @param TPositionerCall* pointer to the TPositionerCall derived class +*/ +void CPositionerQ::PositionerIterator(TPositionerCall& aCall) + { + for(TInt i=0; i < iPsyArray.Count(); ++i) + { + aCall.Call(Positioner(i)); + } + } + +/** +* CPositionerQ::IterETrue +* Calls aCall::Call for all MPositioners in the queue +* @param aCall reference to the TPositionerCall derived function to be called +* @return TBool returns True if the call returns true for any positioner in the queue +*/ +TBool CPositionerQ::IterETrue(TRetBoolPositionerCall& aCall) + { + TInt count = iPsyArray.Count(); + for(TInt i=0; i greatest) + { + greatest = result; + } + } + return greatest; + } + +/* +* CPositionerQ::Count +* +* @return count of MPositioner objects in the queue +*/ +TUint CPositionerQ::Count() + { + return iPsyArray.Count(); + } + +TInt CPositionerQ::Index(MPositioner& aPSY) + { + TInt index = KErrNotFound; + TInt count = iPsyArray.Count(); + + for(TInt i=0; i