1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_EntryArrayData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,210 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "T_EntryArrayData.h"
1.23 +#include "T_EntryData.h"
1.24 +#include "FileserverUtil.h"
1.25 +
1.26 +// Commands
1.27 +_LIT( KCmdCount, "count" );
1.28 +_LIT( KCmdDelete, "~" );
1.29 +_LIT( KCmdNew, "new" );
1.30 +_LIT( KCmdIndexOperator, "[]" );
1.31 +
1.32 +// Parameters
1.33 +_LIT( KParamDestination, "destination" );
1.34 +_LIT( KParamExpected, "expected" );
1.35 +_LIT( KParamIndex, "index" );
1.36 +
1.37 +
1.38 +CT_EntryArrayData* CT_EntryArrayData::NewL()
1.39 +/**
1.40 +* Two phase constructor
1.41 +*/
1.42 + {
1.43 + CT_EntryArrayData* ret = new (ELeave) CT_EntryArrayData();
1.44 + CleanupStack::PushL( ret );
1.45 + ret->ConstructL();
1.46 + CleanupStack::Pop( ret );
1.47 + return ret;
1.48 + }
1.49 +
1.50 +CT_EntryArrayData::CT_EntryArrayData()
1.51 +: iEntryArray(NULL)
1.52 +/**
1.53 +* Protected constructor. First phase construction
1.54 +*/
1.55 + {
1.56 + }
1.57 +
1.58 +void CT_EntryArrayData::ConstructL()
1.59 +/**
1.60 +* Protected constructor. Second phase construction
1.61 +*/
1.62 + {
1.63 + }
1.64 +
1.65 +CT_EntryArrayData::~CT_EntryArrayData()
1.66 +/**
1.67 +* Destructor.
1.68 +*/
1.69 +
1.70 + {
1.71 + DoCmdDelete();
1.72 + }
1.73 +
1.74 +TAny* CT_EntryArrayData::GetObject()
1.75 +/**
1.76 +* Return a pointer to the object that the data wraps
1.77 +*
1.78 +* @return pointer to the object that the data wraps
1.79 +*/
1.80 +
1.81 + {
1.82 + return iEntryArray;
1.83 + }
1.84 +
1.85 +TBool CT_EntryArrayData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
1.86 +/**
1.87 +* Process a command read from the ini file
1.88 +*
1.89 +* @param aCommand the command to process
1.90 +* @param aSection the entry in the ini file requiring the command to be processed
1.91 +*
1.92 +* @return ETrue if the command is processed
1.93 +*/
1.94 + {
1.95 + TBool retVal = ETrue;
1.96 +
1.97 + if ( aCommand == KCmdIndexOperator )
1.98 + {
1.99 + DoCmdIndexOperatorL( aSection );
1.100 + }
1.101 + else if ( aCommand == KCmdCount )
1.102 + {
1.103 + DoCmdCount( aSection );
1.104 + }
1.105 + else if ( aCommand == KCmdDelete )
1.106 + {
1.107 + DoCmdDelete();
1.108 + }
1.109 + else if ( aCommand == KCmdNew )
1.110 + {
1.111 + DoCmdNew();
1.112 + }
1.113 + else
1.114 + {
1.115 + retVal = EFalse;
1.116 + }
1.117 +
1.118 + return retVal;
1.119 + }
1.120 +
1.121 +void CT_EntryArrayData::DoCmdIndexOperatorL( const TDesC& aSection )
1.122 +/**
1.123 +* Assigns an element of TEntryArray to another TEntry object using "=" operator
1.124 +*/
1.125 + {
1.126 + TInt index;
1.127 + TPtrC entryObjectName;
1.128 +
1.129 + if( GET_MANDATORY_INT_PARAMETER( KParamIndex, aSection, index ) &&
1.130 + GET_MANDATORY_STRING_PARAMETER( KParamDestination, aSection, entryObjectName ))
1.131 + {
1.132 + TEntry* entry = new(ELeave) TEntry();
1.133 + CleanupStack::PushL(entry);
1.134 +
1.135 + *entry = iEntryArray->operator[](index);
1.136 + CT_EntryData* entryWrapperObject = static_cast<CT_EntryData*>(GetDataWrapperL(entryObjectName));
1.137 +
1.138 + if(!entryWrapperObject)
1.139 + {
1.140 + ERR_PRINTF2(_L("%S is not initialised"), &entryObjectName);
1.141 + SetBlockResult(EFail);
1.142 + CleanupStack::PopAndDestroy(entry);
1.143 + }
1.144 + else
1.145 + {
1.146 + entryWrapperObject->SetObjectL(entry);
1.147 + CleanupStack::Pop(entry);
1.148 + }
1.149 + }
1.150 + }
1.151 +
1.152 +void CT_EntryArrayData::DoCmdCount( const TDesC& aSection )
1.153 +/**
1.154 +* Checks if TEntryArray has expected number of elements
1.155 +*/
1.156 + {
1.157 + TInt expected;
1.158 + if( GET_MANDATORY_INT_PARAMETER( KParamExpected, aSection, expected ) )
1.159 + {
1.160 + INFO_PRINTF2( _L( "Count(). Expected value = %d" ), expected );
1.161 +
1.162 + TInt result = iEntryArray->Count();
1.163 + if ( result != expected )
1.164 + {
1.165 + ERR_PRINTF3(_L("Count %d != expected %d"), result, expected );
1.166 + SetBlockResult( EFail );
1.167 + }
1.168 + }
1.169 + }
1.170 +
1.171 +void CT_EntryArrayData::DoCmdDelete()
1.172 +/**
1.173 +* Deletes TEntryArray class instance
1.174 +*/
1.175 + {
1.176 + DoCleanup();
1.177 + }
1.178 +
1.179 +void CT_EntryArrayData::DoCmdNew()
1.180 +/**
1.181 +* Creates new TEntryArray class instance
1.182 +*/
1.183 + {
1.184 + DoCmdDelete();
1.185 +
1.186 + INFO_PRINTF1( _L( "Create new TEntryArray() class instance." ) );
1.187 + TRAPD( err, iEntryArray = new (ELeave) TEntryArray() );
1.188 + if ( err != KErrNone )
1.189 + {
1.190 + ERR_PRINTF2( _L( "new TEntryArray() error %d" ), err );
1.191 + SetBlockResult( EFail );
1.192 + }
1.193 + }
1.194 +
1.195 +
1.196 +void CT_EntryArrayData::SetObjectL( TAny* aAny )
1.197 +/**
1.198 +* Set the wrapped data object with new value
1.199 +*/
1.200 + {
1.201 + DoCleanup();
1.202 + iEntryArray = static_cast<TEntryArray*> ( aAny );
1.203 + }
1.204 +
1.205 +void CT_EntryArrayData::DoCleanup()
1.206 +/** Deltes TEntry class instance */
1.207 + {
1.208 + INFO_PRINTF1( _L( "Delete TEntryArray class instance" ) );
1.209 + delete iEntryArray;
1.210 + iEntryArray = NULL;
1.211 + }
1.212 +
1.213 +