|
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 #ifndef VPBKSIMSTOREIMPL_CCOMPOSITECMDBASE_H |
|
21 #define VPBKSIMSTOREIMPL_CCOMPOSITECMDBASE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <MVPbkSimCommand.h> |
|
26 #include <MVPbkSimCommandObserver.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 |
|
31 namespace VPbkSimStoreImpl { |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * A command base class |
|
37 * |
|
38 */ |
|
39 NONSHARABLE_CLASS(CCompositeCmdBase) : public CBase, |
|
40 public MVPbkSimCommand, |
|
41 private MVPbkSimCommandObserver |
|
42 { |
|
43 public: // Destruction |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CCompositeCmdBase(); |
|
49 |
|
50 public: // New functions |
|
51 |
|
52 /** |
|
53 * Adds a new subcommand to this composite |
|
54 * |
|
55 * @param aSubCommand A new subcommand to the composite. |
|
56 */ |
|
57 void AddSubCommandL( MVPbkSimCommand* aSubCommand ); |
|
58 |
|
59 public: // Functions from base classes |
|
60 |
|
61 /** |
|
62 * Subclass must handle command execution logic |
|
63 */ |
|
64 virtual void Execute() = 0; |
|
65 |
|
66 /** |
|
67 * From MVPbkSimCommand. |
|
68 * Only one observer supported. |
|
69 */ |
|
70 void AddObserverL( MVPbkSimCommandObserver& aObserver ); |
|
71 |
|
72 /** |
|
73 * From MVPbkSimCommand |
|
74 */ |
|
75 void CancelCmd(); |
|
76 |
|
77 private: // Functions from base classes |
|
78 |
|
79 /** |
|
80 * From MVPbkSimCommandObserver |
|
81 * Subclass must implement the logic for this |
|
82 */ |
|
83 virtual void CommandDone( MVPbkSimCommand& aCommand ) = 0; |
|
84 |
|
85 /** |
|
86 * From MVPbkSimCommandObserver. |
|
87 * Default error handling is to forward error to composite's |
|
88 * observer. |
|
89 */ |
|
90 void CommandError( MVPbkSimCommand& aCommand, TInt aError ); |
|
91 |
|
92 protected: |
|
93 |
|
94 /** |
|
95 * C++ constructor. |
|
96 */ |
|
97 CCompositeCmdBase(); |
|
98 |
|
99 /** |
|
100 * Returns the subcommands for the subclass. |
|
101 * |
|
102 * @return An array of subcommands. |
|
103 */ |
|
104 inline TArray<MVPbkSimCommand*> SubCommands(); |
|
105 |
|
106 /** |
|
107 * Sends command done event to composite's observer |
|
108 */ |
|
109 void SendCommandDone(); |
|
110 |
|
111 /** |
|
112 * Sends command error event to composite's observer |
|
113 */ |
|
114 void SendCommandError( TInt aError ); |
|
115 |
|
116 private: // Data |
|
117 /// Ref: the command that runs after this or NULL |
|
118 RPointerArray<MVPbkSimCommand> iSubCommands; |
|
119 /// Ref: The observer of this command |
|
120 RPointerArray<MVPbkSimCommandObserver> iObservers; |
|
121 }; |
|
122 |
|
123 // INLINE FUNCTIONS |
|
124 inline TArray<MVPbkSimCommand*> CCompositeCmdBase::SubCommands() |
|
125 { |
|
126 return iSubCommands.Array(); |
|
127 } |
|
128 } // namespace VPbkSimStoreImpl |
|
129 #endif // VPBKSIMSTOREIMPL_CCOMPOSITECMDBASE_H |
|
130 |
|
131 // End of File |