|
1 /* |
|
2 * Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: A composite command that runs subcommands parallel. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CSequentialCompositeCmd.h" |
|
22 |
|
23 #include <VPbkDebug.h> |
|
24 #include <MVPbkSimCommandObserver.h> |
|
25 #include "VPbkSimStoreImplError.h" |
|
26 |
|
27 namespace VPbkSimStoreImpl { |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CSequentialCompositeCmd::CSequentialCompositeCmd |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CSequentialCompositeCmd::CSequentialCompositeCmd() |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSequentialCompositeCmd::NewL |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSequentialCompositeCmd* CSequentialCompositeCmd::NewL() |
|
46 { |
|
47 return new( ELeave ) CSequentialCompositeCmd; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CSequentialCompositeCmd::NewLC |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CSequentialCompositeCmd* CSequentialCompositeCmd::NewLC() |
|
55 { |
|
56 CSequentialCompositeCmd* self = |
|
57 new( ELeave ) CSequentialCompositeCmd; |
|
58 CleanupStack::PushL( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // Destructor |
|
63 CSequentialCompositeCmd::~CSequentialCompositeCmd() |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSequentialCompositeCmd::Execute |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CSequentialCompositeCmd::Execute() |
|
72 { |
|
73 __ASSERT_DEBUG( SubCommands().Count() > 0, |
|
74 VPbkSimStoreImpl::Panic( EPreCondCSequentialCompositeCmdExecute ) ); |
|
75 |
|
76 iCommandCursor = 0; |
|
77 // Execute first command |
|
78 TArray<MVPbkSimCommand*> subCommands = SubCommands(); |
|
79 if ( subCommands.Count() > 0 ) |
|
80 { |
|
81 subCommands[iCommandCursor]->Execute(); |
|
82 } |
|
83 else |
|
84 { |
|
85 SendCommandDone(); |
|
86 } |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CSequentialCompositeCmd::CommandDone |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CSequentialCompositeCmd::CommandDone( MVPbkSimCommand& /*aCommand*/ ) |
|
94 { |
|
95 ++iCommandCursor; |
|
96 TArray<MVPbkSimCommand*> subCommands = SubCommands(); |
|
97 if ( iCommandCursor < subCommands.Count() ) |
|
98 { |
|
99 subCommands[iCommandCursor]->Execute(); |
|
100 } |
|
101 else |
|
102 { |
|
103 SendCommandDone(); |
|
104 } |
|
105 } |
|
106 } // namespace VPbkSimStoreImpl |
|
107 // End of File |