|
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 base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CCompositeCmdBase.h" |
|
22 |
|
23 #include <VPbkDebug.h> |
|
24 #include "VPbkSimStoreImplError.h" |
|
25 #include "MVPbkSimCommandObserver.h" |
|
26 |
|
27 namespace VPbkSimStoreImpl { |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CCompositeCmdBase::CCompositeCmdBase |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CCompositeCmdBase::CCompositeCmdBase() |
|
38 { |
|
39 } |
|
40 |
|
41 // Destructor |
|
42 CCompositeCmdBase::~CCompositeCmdBase() |
|
43 { |
|
44 iObservers.Close(); |
|
45 iSubCommands.ResetAndDestroy(); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCompositeCmdBase::AddSubCommandL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CCompositeCmdBase::AddSubCommandL( MVPbkSimCommand* aSubCommand ) |
|
53 { |
|
54 __ASSERT_DEBUG( aSubCommand, |
|
55 VPbkSimStoreImpl::Panic( EPreCondCCompositeCmdBaseAddSubCommandL ) ); |
|
56 iSubCommands.AppendL( aSubCommand ); |
|
57 aSubCommand->AddObserverL( *this ); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CCompositeCmdBase::AddObserverL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CCompositeCmdBase::AddObserverL( MVPbkSimCommandObserver& aObserver ) |
|
65 { |
|
66 iObservers.AppendL( &aObserver ); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CCompositeCmdBase::CancelCmd |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CCompositeCmdBase::CancelCmd() |
|
74 { |
|
75 const TInt count = iSubCommands.Count(); |
|
76 for ( TInt i = 0; i < count; ++i ) |
|
77 { |
|
78 iSubCommands[i]->CancelCmd(); |
|
79 } |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CCompositeCmdBase::CommandError |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CCompositeCmdBase::CommandError( MVPbkSimCommand& /*aCommand*/, |
|
87 TInt aError ) |
|
88 { |
|
89 // Cancel all other subcommands |
|
90 CancelCmd(); |
|
91 SendCommandError( aError ); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CCompositeCmdBase::SendCommandDone |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CCompositeCmdBase::SendCommandDone() |
|
99 { |
|
100 const TInt count = iObservers.Count(); |
|
101 for ( TInt i = count - 1; i >= 0; --i ) |
|
102 { |
|
103 iObservers[i]->CommandDone( *this ); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CCompositeCmdBase::SendCommandError |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CCompositeCmdBase::SendCommandError( TInt aError ) |
|
112 { |
|
113 const TInt count = iObservers.Count(); |
|
114 for ( TInt i = count - 1; i >= 0; --i ) |
|
115 { |
|
116 iObservers[i]->CommandError( *this, aError ); |
|
117 } |
|
118 } |
|
119 } // namespace VPbkSimStoreImpl |
|
120 // End of File |