diff -r 000000000000 -r e686773b3f54 phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/CSequentialCompositeCmd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/CSequentialCompositeCmd.cpp Tue Feb 02 10:12:17 2010 +0200 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2007-2007 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: A composite command that runs subcommands parallel. +* +*/ + + + +// INCLUDE FILES +#include "CSequentialCompositeCmd.h" + +#include +#include +#include "VPbkSimStoreImplError.h" + +namespace VPbkSimStoreImpl { + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CSequentialCompositeCmd::CSequentialCompositeCmd +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CSequentialCompositeCmd::CSequentialCompositeCmd() + { + } + +// ----------------------------------------------------------------------------- +// CSequentialCompositeCmd::NewL +// ----------------------------------------------------------------------------- +// +CSequentialCompositeCmd* CSequentialCompositeCmd::NewL() + { + return new( ELeave ) CSequentialCompositeCmd; + } + +// ----------------------------------------------------------------------------- +// CSequentialCompositeCmd::NewLC +// ----------------------------------------------------------------------------- +// +CSequentialCompositeCmd* CSequentialCompositeCmd::NewLC() + { + CSequentialCompositeCmd* self = + new( ELeave ) CSequentialCompositeCmd; + CleanupStack::PushL( self ); + return self; + } + +// Destructor +CSequentialCompositeCmd::~CSequentialCompositeCmd() + { + } + +// ----------------------------------------------------------------------------- +// CSequentialCompositeCmd::Execute +// ----------------------------------------------------------------------------- +// +void CSequentialCompositeCmd::Execute() + { + __ASSERT_DEBUG( SubCommands().Count() > 0, + VPbkSimStoreImpl::Panic( EPreCondCSequentialCompositeCmdExecute ) ); + + iCommandCursor = 0; + // Execute first command + TArray subCommands = SubCommands(); + if ( subCommands.Count() > 0 ) + { + subCommands[iCommandCursor]->Execute(); + } + else + { + SendCommandDone(); + } + } + +// ----------------------------------------------------------------------------- +// CSequentialCompositeCmd::CommandDone +// ----------------------------------------------------------------------------- +// +void CSequentialCompositeCmd::CommandDone( MVPbkSimCommand& /*aCommand*/ ) + { + ++iCommandCursor; + TArray subCommands = SubCommands(); + if ( iCommandCursor < subCommands.Count() ) + { + subCommands[iCommandCursor]->Execute(); + } + else + { + SendCommandDone(); + } + } +} // namespace VPbkSimStoreImpl +// End of File