diff -r 000000000000 -r 8e480a14352b messagingfw/msgtestfw/Framework/src/CMtfTestParameterStore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgtestfw/Framework/src/CMtfTestParameterStore.cpp Mon Jan 18 20:36:02 2010 +0200 @@ -0,0 +1,87 @@ +// Copyright (c) 2003-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 +*/ + +#include "CMtfTestParameterStore.h" +#include "CMtfTestAction.h" +#include "CMtfTestParameter.h" + +CMtfTestParameterStore* CMtfTestParameterStore::NewL() +{ + CMtfTestParameterStore* self = new (ELeave) CMtfTestParameterStore; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +CMtfTestParameterStore::CMtfTestParameterStore() +{ +} + +void CMtfTestParameterStore::ConstructL() +{ +} + +CMtfTestParameterStore::~CMtfTestParameterStore() +{ + iParameters.ResetAndDestroy(); +} + +/** Stores a parameter at the beginning of the array. The parameter is stored at the +beginning of the array so that when the object is deleted, the last stored parameter is +deleted first. The function takes ownership of aParameter at the END. */ +void CMtfTestParameterStore::StoreParameterL(CMtfTestParameter* aParameter) +{ + User::LeaveIfError(iParameters.Insert(aParameter,0)); +} + +TInt CMtfTestParameterStore::ObtainParameterIndexL(const TDesC& aParameterName) const +{ + TInt parameterCount = iParameters.Count(); + TInt count; + TBool parameterFound = EFalse; + + for(count=0; countName() == aParameterName) + { + parameterFound = ETrue; + break; + } + } + + if (!parameterFound) + { + User::Leave(KErrNotFound); + } + + return count; +} + +const CMtfTestParameter& CMtfTestParameterStore::ObtainParameterL(const TDesC& aParameterName) const +{ + return *iParameters[ObtainParameterIndexL(aParameterName)]; +} + +void CMtfTestParameterStore::DeleteParameterL(const TDesC& aParameterName) +{ + TInt index = ObtainParameterIndexL(aParameterName); + delete iParameters[index]; + iParameters.Remove(index); +}