|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The implementation of a some classes |
|
15 // to be provided by ECom. |
|
16 // 1. Using the CExampleInterface class as a base. |
|
17 // |
|
18 // |
|
19 |
|
20 #include "Interface.h" |
|
21 #include "ImplementationProxy.h" |
|
22 #include "TestUtilities.h" // For __FILE__LINE__ |
|
23 |
|
24 // ____________________________________________________________________________ |
|
25 // |
|
26 /** |
|
27 Intended usage: This class implements the functionality promised by |
|
28 the CExampleInterface defintion class. It does little apart from provides a test instance |
|
29 which may be retrieved and run for testing purposes. |
|
30 Its resolution is based upon its registered default data string that |
|
31 advertises this class as being able to handle 'text\wml' data. |
|
32 @since 7.0 |
|
33 */ |
|
34 class CImplementationClassFour : public CExampleInterface |
|
35 { |
|
36 // Methods |
|
37 public: |
|
38 /** |
|
39 @fn NewL(TAny* aInitParams) |
|
40 Intended Usage : Standardised safe construction which leaves nothing the cleanup stack. |
|
41 Error Condition : Leaves with error code. |
|
42 @leave KErrNoMemory. |
|
43 @since 7.0 |
|
44 @param aInitParams The parameter struct used for initialising this object |
|
45 @return CImplementationClassFour* The class instance. |
|
46 @pre None |
|
47 @post CImplementationClassFour has been constructed, |
|
48 and initialised. |
|
49 */ |
|
50 static CImplementationClassFour* NewL(TAny* aInitParams); |
|
51 |
|
52 /** |
|
53 @fn ~CImplementationClassFour() |
|
54 Intended Usage : Default Destructor |
|
55 Error Condition : None |
|
56 @since 7.0 |
|
57 @pre CImplementationClassFour has been constructed |
|
58 @post CImplementationClassFour has been completely destroyed. |
|
59 */ |
|
60 virtual ~CImplementationClassFour(); |
|
61 |
|
62 /** |
|
63 @fn DoMethodL() |
|
64 Intended Usage : Overload of the pure interface method |
|
65 Representative of a method provided on |
|
66 the interface by the interface definer. |
|
67 Error Condition : Leaves with an error code. |
|
68 @leave KErrNoMemory, KErrNotSupported. |
|
69 @since 7.0 |
|
70 @return None |
|
71 @pre CImplementationClassFour has been constructed |
|
72 @post Unspecified |
|
73 */ |
|
74 void DoMethodL(); |
|
75 |
|
76 /** |
|
77 @fn FireAndForget() |
|
78 Intended Usage : Overload of the pure interface method |
|
79 asynchronous function which |
|
80 an interface definer could specify. |
|
81 It allows the client to call the function in the knowledge |
|
82 that the object will commit suicide when the |
|
83 function completes. |
|
84 Error Condition : None. |
|
85 @since 7.0 |
|
86 @return TInt KErrNone for success. |
|
87 @pre CImplementationClassFour has been constructed |
|
88 @post Unspecified |
|
89 */ |
|
90 TInt FireAndForget(); |
|
91 |
|
92 /** |
|
93 @fn ImplId() |
|
94 Intended Usage : To verify the object returned by ECOM. |
|
95 Error Condition : None. |
|
96 @since 7.0 |
|
97 @return TUid (ECOM's Implementation Uid for this class.) |
|
98 @pre CImplementationClassThree has been constructed |
|
99 @post Unspecified |
|
100 */ |
|
101 TUid ImplId(); |
|
102 |
|
103 private: |
|
104 /** |
|
105 @fn CImplementationClassFour() |
|
106 Intended Usage : Default Constructor : usable only by derived classes |
|
107 Error Condition : None |
|
108 @since 7.0 |
|
109 @pre None |
|
110 @post CImplementationClassFour has been constructed |
|
111 */ |
|
112 CImplementationClassFour(); |
|
113 |
|
114 /** |
|
115 @fn ConstructL(TAny* aInitParams) |
|
116 Intended Usage : Completes the safe construction of the CImplementationClassFour object |
|
117 Error Condition : Leaves with the error code. |
|
118 @leave KErrNoMemory. |
|
119 @since 7.0 |
|
120 @param aInitParams The parameter struct used for initialising this object |
|
121 @pre CImplementationClassFour has been constructed |
|
122 @post CImplementationClassFour has been fully initialised. |
|
123 */ |
|
124 void ConstructL(TAny* aInitParams); |
|
125 |
|
126 // Provide the CActive overloads |
|
127 void RunL(); |
|
128 void DoCancel(); |
|
129 TInt RunError(TInt aError); |
|
130 |
|
131 private: |
|
132 /** A place for allocating some memory in the ConstructL */ |
|
133 HBufC* iInternalDescriptor; |
|
134 /** An int to be stored in TLS to test its useage */ |
|
135 TInt iTLSInt; |
|
136 |
|
137 }; // End of CImplementationClassFour definition |
|
138 |
|
139 // __________________________________________________________________________ |
|
140 // Implementation |
|
141 |
|
142 CImplementationClassFour* CImplementationClassFour::NewL(TAny* aInitParams) |
|
143 // Intended Usage : Safe construction which leaves nothing upon the cleanup stack |
|
144 // Error Condition : Will leave with an appropriate error code |
|
145 // Dependencies : CBase |
|
146 // @param " " |
|
147 // @return CImplementationClassFour* a pointer to the fully instantiated CImplementationClassFour object |
|
148 // @pre None |
|
149 // @post The object has been fully instantiated |
|
150 // Static member |
|
151 { |
|
152 CImplementationClassFour* self=new(ELeave) CImplementationClassFour(); // calls c'tor |
|
153 CleanupStack::PushL(self); // Make the construction safe by using the cleanup stack |
|
154 self->ConstructL(aInitParams); // Complete the 'construction'. |
|
155 CleanupStack::Pop(self); |
|
156 return self; |
|
157 } |
|
158 |
|
159 CImplementationClassFour::~CImplementationClassFour() |
|
160 // Default virtual d'tor |
|
161 { |
|
162 delete iInternalDescriptor; |
|
163 } |
|
164 |
|
165 CImplementationClassFour::CImplementationClassFour() |
|
166 // Default c'tor for use by derived and |
|
167 // static construction methods only |
|
168 : CExampleInterface() |
|
169 { |
|
170 // Deliberately do nothing here : See ConstructL() for initialisation completion. |
|
171 } |
|
172 |
|
173 void CImplementationClassFour::ConstructL(TAny* aInitParams) |
|
174 // Intended Usage : Safely complete the initialization of the constructed object |
|
175 // Error Condition : Will leave with an appropriate error code |
|
176 // Dependencies : CBase |
|
177 // @return void |
|
178 // @pre CImplementationClassFour has been constructed |
|
179 // @post The CImplementationClassFour object has been fully instantiated |
|
180 // |
|
181 { |
|
182 TExampleInterfaceInitParams* params = REINTERPRET_CAST(TExampleInterfaceInitParams*, |
|
183 aInitParams); |
|
184 if(params->descriptor) |
|
185 iInternalDescriptor = params->descriptor->AllocL(); |
|
186 |
|
187 Dll::SetTls(&iTLSInt); |
|
188 } |
|
189 |
|
190 void CImplementationClassFour::DoMethodL() |
|
191 { |
|
192 // Access TLS to ensure it has been set properly |
|
193 REINTERPRET_CAST(TInt*, Dll::Tls()); |
|
194 } |
|
195 |
|
196 TInt CImplementationClassFour::FireAndForget() |
|
197 { |
|
198 TRAPD(error,DoMethodL()); |
|
199 return error; // Always KErrNotSupported |
|
200 } |
|
201 |
|
202 // Provide the CActive overloads |
|
203 void CImplementationClassFour::RunL() |
|
204 { |
|
205 // Do nothing : should never be called |
|
206 __ASSERT_DEBUG(EFalse,User::Invariant()); |
|
207 } |
|
208 |
|
209 void CImplementationClassFour::DoCancel() |
|
210 { |
|
211 // Do nothing |
|
212 } |
|
213 |
|
214 TInt CImplementationClassFour::RunError(TInt /*aError*/) |
|
215 { |
|
216 return KErrNone; |
|
217 } |
|
218 |
|
219 TUid CImplementationClassFour::ImplId() |
|
220 { |
|
221 TUid idVal = {0x101F847A}; |
|
222 return (idVal); |
|
223 } |
|
224 |
|
225 // __________________________________________________________________________ |
|
226 // Exported proxy for instantiation method resolution |
|
227 // Define the interface UIDs |
|
228 const TImplementationProxy ImplementationTable[] = |
|
229 { |
|
230 IMPLEMENTATION_PROXY_ENTRY(0x101F847A, CImplementationClassFour::NewL) |
|
231 }; |
|
232 |
|
233 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
234 { |
|
235 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
236 return ImplementationTable; |
|
237 } |
|
238 |