landmarks/locationlandmarks/localaccess/src/EPos_CPosLmLocalIterator.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:40:52 +0300
changeset 32 b12ea03c50a3
parent 0 667063e416a2
child 39 3efc7a0e8755
permissions -rw-r--r--
Revision: 201023 Kit: 2010125

/*
* Copyright (c) 2002-2005 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: Local iterator base class.
*
*
*/


#include    <EPos_LandmarksErrors.h>
#include    "EPos_CPosLmLocalIterator.h"

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
CPosLmLocalIterator::CPosLmLocalIterator() :
    CPosLmItemIterator()
    {
    }

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
CPosLmLocalIterator::~CPosLmLocalIterator()
    {
    iIdArray.Close();
    }

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
TPosLmItemId CPosLmLocalIterator::NextL()
    {
    if (iCurrent >= iIdArray.Count())
        {
        return KPosLmNullItemId;
        }

    return iIdArray[iCurrent++];
    }

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void CPosLmLocalIterator::Reset()
    {
    iCurrent = 0;
    }

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
TUint CPosLmLocalIterator::NumOfItemsL()
    {
    return iIdArray.Count();
    }

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void CPosLmLocalIterator::GetItemIdsL(
    RArray<TPosLmItemId>& aIdArray,
    TInt aStartIndex,
    TInt aNumOfItems)
    {
    if (aStartIndex < 0 || aStartIndex >= iIdArray.Count() ||
        aStartIndex + aNumOfItems > iIdArray.Count())
        {
        Panic(KPosLandmarksClientPanic,
            EPosSpecifiedIntervalLiesOutsideIteratedSet);
        }

    aIdArray.Reset();
    aIdArray.ReserveL( aNumOfItems ); // to avoid heap fragmentation
    for (TInt i = aStartIndex; i < aStartIndex + aNumOfItems; i++)
        {
        aIdArray.Append( iIdArray[i] );
        }
    }