diff -r 000000000000 -r a2952bb97e68 mpx/commonframework/common/inc/mpxfixedarray.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpx/commonframework/common/inc/mpxfixedarray.inl Thu Dec 17 08:55:47 2009 +0200 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2006 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: Implementation of array of fixed size elements on global chunk +* +*/ + + +// ----------------------------------------------------------------------------- +// RMPXFixedArrayBase::Close +// ----------------------------------------------------------------------------- +// +inline void RMPXFixedArrayBase::Close(TUint aClientHandle) + { + Reset(aClientHandle); + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArrayBase::Buf +// ----------------------------------------------------------------------------- +// +inline TAny* RMPXFixedArrayBase::Buf(TUint aClientHandle) const + { + return RMPXHeapManager::Ptr(aClientHandle,iDataOffset); + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArrayBase::Count +// ----------------------------------------------------------------------------- +// +inline TInt RMPXFixedArrayBase::Count() const + { + return iCount; + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArray::RMPXFixedArray +// ----------------------------------------------------------------------------- +// +template +inline RMPXFixedArray::RMPXFixedArray(const RMPXFixedArray& aArray) + : RMPXFixedArrayBase(aArray,sizeof(T)) + { + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArray::RMPXFixedArray +// ----------------------------------------------------------------------------- +// +template +inline RMPXFixedArray::RMPXFixedArray() + : RMPXFixedArrayBase(sizeof(T)) + { + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArray::Copy +// ----------------------------------------------------------------------------- +// +template +inline TInt RMPXFixedArray::Copy(TUint aClientHandle,const TArray& aArray) + { + TInt n=aArray.Count(); + T* ptr=(T*)RMPXFixedArrayBase::Alloc(aClientHandle,n); + if (ptr) + { + for (TInt i=0;i +inline TArray RMPXFixedArray::Array(TUint aClientHandle) const + { + TInt thisOffset=RMPXHeapManager::Offset(aClientHandle,(TAny*)this); + return TArray(CountFunctionR,AtFunctionR,reinterpret_cast(thisOffset)); + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArray::CountFunctionR +// ----------------------------------------------------------------------------- +// +template +inline TInt RMPXFixedArray::CountFunctionR(const CBase* aThis) + { + // Non-optimal, obtaining client handle every time count is accessed, however + // there's no choice since the data could be shared by multiple threads and the + // function signature does not allow the handle to be passed through + // + TInt offset=reinterpret_cast(aThis); + TInt ch=RMPXHeapManager::ClientHandle(); + const RMPXFixedArrayBase* arr=RMPXHeapManager::Ptr(ch,offset); + return arr->Count(); + } + +// ----------------------------------------------------------------------------- +// RMPXFixedArray::AtFunctionR +// ----------------------------------------------------------------------------- +// +template +inline const TAny* RMPXFixedArray::AtFunctionR(const CBase* aThis,TInt aIndex) + { + // Non-optimal, obtaining client handle every time data is accessed, however + // there's no choice since the data could be shared by multiple threads and the + // function signature does not allow the handle to be passed through + // + TInt offset=reinterpret_cast(aThis); + TInt ch=RMPXHeapManager::ClientHandle(); + const RMPXFixedArrayBase* arr=RMPXHeapManager::Ptr(ch,offset); + T* ptr=(T*)arr->Buf(ch); + return &ptr[aIndex]; + } + +// End of file +