persistentstorage/store/USTOR/UT_Iter.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "S32STOR.H"
       
    17 #include "S32FILE.H"
       
    18 #include "U32PERM.H"
       
    19 #include "S32FileIter.h"
       
    20 
       
    21 /**
       
    22 After calling Close() RPermanentFileStoreIter instance could be used again
       
    23 with the same or some other CPermanentFileStore instance.
       
    24 */
       
    25 EXPORT_C void RPermanentFileStoreIter::Close()
       
    26 	{
       
    27 	if(iImpl)
       
    28 		{
       
    29 		iImpl->Close();
       
    30 		}
       
    31 	delete iImpl;
       
    32 	iImpl = NULL;
       
    33 	}
       
    34 
       
    35 /**
       
    36 Starts a CPermanentFileStore stream IDs iteration.
       
    37 @param aStore CPermanentFileStore instance, which stream IDs sequence we want to 
       
    38 explore.
       
    39 @leave KErrNoMemory
       
    40 */
       
    41 EXPORT_C void RPermanentFileStoreIter::ResetLC(const CPermanentFileStore& aStore)
       
    42 	{
       
    43 	__ASSERT_DEBUG(!iImpl, User::Invariant());
       
    44 	::CleanupClosePushL(*this);
       
    45 	CPermanentStoreCoord& coord = aStore.CoordL();
       
    46 	CPermanentStoreToc& table = coord.TableL();
       
    47 	iImpl = new (ELeave) RPermanentStoreTocIter(table);
       
    48 	iImpl->ResetL();
       
    49 	}
       
    50 
       
    51 /**
       
    52 Retrieves the next stream ID from stream IDs sequence, controlled by CPermanentFileStore 
       
    53 instance. 
       
    54 @return The next stream ID or KNullStreamIdValue if there are no more stream IDs.
       
    55 @leave KErrNoMemory
       
    56 */
       
    57 EXPORT_C TStreamId RPermanentFileStoreIter::NextL()
       
    58 	{
       
    59 	__ASSERT_DEBUG(iImpl, User::Invariant());
       
    60 	TStreamId streamId = KNullStreamIdValue;
       
    61 	CPermanentStoreToc::TEntry entry;
       
    62 	while(iImpl->NextL(entry))
       
    63 		{
       
    64 		if((TUint32)entry.handle < KMaxStreamIdValue)
       
    65 			{
       
    66 			streamId = entry.handle;
       
    67 			break;
       
    68 			}
       
    69 		}
       
    70 	return streamId;
       
    71 	}