|
1 /* |
|
2 * Copyright (c) 2001-2006 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 the License "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: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #if !defined(_EAP_AUTOMATIC_VARIABLE_H_) |
|
22 #define _EAP_AUTOMATIC_VARIABLE_H_ |
|
23 |
|
24 |
|
25 #include "eap_am_memory.h" |
|
26 #include "eap_tools.h" |
|
27 #include "eap_am_tools.h" |
|
28 #include "eap_am_export.h" |
|
29 |
|
30 /** |
|
31 * @{ Add some comments. } |
|
32 */ |
|
33 template <class Type> |
|
34 class EAP_EXPORT eap_automatic_variable_c |
|
35 { |
|
36 private: |
|
37 abs_eap_am_tools_c * const m_am_tools; |
|
38 |
|
39 /// This is the pointer to the actual object that will be deleted if different than zero. |
|
40 Type *m_data; |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * The destructor deletes the object in this atom if necessary. |
|
46 */ |
|
47 virtual ~eap_automatic_variable_c() |
|
48 { |
|
49 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
50 if (m_data != 0) |
|
51 { |
|
52 delete m_data; |
|
53 m_data = 0; |
|
54 } |
|
55 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
56 } |
|
57 |
|
58 /** |
|
59 * The constructor sets the values for the member variables |
|
60 */ |
|
61 eap_automatic_variable_c( |
|
62 abs_eap_am_tools_c * const tools, |
|
63 Type * const p_data) |
|
64 : m_am_tools(tools) |
|
65 , m_data(p_data) |
|
66 { |
|
67 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
68 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
69 } |
|
70 |
|
71 /** |
|
72 * The constructor sets the values for the member variables |
|
73 */ |
|
74 eap_automatic_variable_c( |
|
75 abs_eap_am_tools_c * const tools) |
|
76 : m_am_tools(tools) |
|
77 , m_data(0) |
|
78 { |
|
79 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
80 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
81 } |
|
82 |
|
83 /** |
|
84 * This function sets the data. |
|
85 */ |
|
86 void set_variable(Type * const p_data) |
|
87 { |
|
88 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
89 |
|
90 m_data = p_data; |
|
91 |
|
92 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
93 } |
|
94 |
|
95 // |
|
96 void do_not_free_variable() |
|
97 { |
|
98 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
99 |
|
100 m_data = 0; |
|
101 |
|
102 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
103 } |
|
104 }; |
|
105 |
|
106 //-------------------------------------------------- |
|
107 |
|
108 /** |
|
109 * @{ Add some comments. } |
|
110 */ |
|
111 template <class Type> |
|
112 class EAP_EXPORT eap_automatic_array_variable_c |
|
113 { |
|
114 private: |
|
115 abs_eap_am_tools_c * const m_am_tools; |
|
116 |
|
117 /// This is the pointer to the actual object array that will be deleted if different than zero. |
|
118 Type *m_data; |
|
119 |
|
120 public: |
|
121 |
|
122 /** |
|
123 * The destructor deletes the object in this atom if necessary. |
|
124 */ |
|
125 virtual ~eap_automatic_array_variable_c() |
|
126 { |
|
127 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
128 if (m_data != 0) |
|
129 { |
|
130 delete [] m_data; |
|
131 m_data = 0; |
|
132 } |
|
133 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
134 } |
|
135 |
|
136 /** |
|
137 * The constructor sets the values for the member variables |
|
138 */ |
|
139 eap_automatic_array_variable_c( |
|
140 abs_eap_am_tools_c * const tools, |
|
141 Type * const p_data) |
|
142 : m_am_tools(tools) |
|
143 , m_data(p_data) |
|
144 { |
|
145 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
146 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
147 } |
|
148 |
|
149 /** |
|
150 * The constructor sets the values for the member variables |
|
151 */ |
|
152 void set_variable(Type * const p_data) |
|
153 { |
|
154 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
155 |
|
156 m_data = p_data; |
|
157 |
|
158 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
159 } |
|
160 |
|
161 // |
|
162 void do_not_free_variable() |
|
163 { |
|
164 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
165 |
|
166 m_data = 0; |
|
167 |
|
168 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
169 } |
|
170 }; |
|
171 |
|
172 //-------------------------------------------------- |
|
173 |
|
174 /** |
|
175 * @{ Add some comments. } |
|
176 */ |
|
177 template <class Type> |
|
178 class EAP_EXPORT eap_automatic_simple_value_c |
|
179 { |
|
180 private: |
|
181 abs_eap_am_tools_c * const m_am_tools; |
|
182 |
|
183 /// This is pointer to the variable that will be restored on destructor. |
|
184 Type *m_restored_variable; |
|
185 |
|
186 /// This is the value that will be set on destructor. |
|
187 Type m_data; |
|
188 |
|
189 public: |
|
190 |
|
191 /** |
|
192 * The destructor deletes the object in this atom if necessary. |
|
193 */ |
|
194 virtual ~eap_automatic_simple_value_c() |
|
195 { |
|
196 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
197 |
|
198 if (m_restored_variable != 0) |
|
199 { |
|
200 *m_restored_variable = m_data; |
|
201 } |
|
202 |
|
203 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
204 } |
|
205 |
|
206 /** |
|
207 * The constructor sets the values for the member variables |
|
208 */ |
|
209 eap_automatic_simple_value_c( |
|
210 abs_eap_am_tools_c * const tools, |
|
211 Type * const p_restored_variable, |
|
212 const Type p_data) |
|
213 : m_am_tools(tools) |
|
214 , m_restored_variable(p_restored_variable) |
|
215 , m_data(p_data) |
|
216 { |
|
217 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
218 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
219 } |
|
220 |
|
221 // |
|
222 void do_not_restore_variable() |
|
223 { |
|
224 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
225 |
|
226 m_restored_variable = 0; |
|
227 |
|
228 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
229 } |
|
230 }; |
|
231 |
|
232 |
|
233 //-------------------------------------------------- |
|
234 |
|
235 /** |
|
236 * @{ Add some comments. } |
|
237 */ |
|
238 class EAP_EXPORT eap_automatic_trace_string_c |
|
239 { |
|
240 private: |
|
241 abs_eap_am_tools_c * const m_am_tools; |
|
242 |
|
243 /// This is pointer to the string that will be traced on destructor. |
|
244 eap_format_string m_string; |
|
245 |
|
246 public: |
|
247 |
|
248 /** |
|
249 * The destructor traces the string. |
|
250 */ |
|
251 virtual ~eap_automatic_trace_string_c() |
|
252 { |
|
253 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
254 |
|
255 if (m_string != 0) |
|
256 { |
|
257 EAP_TRACE_DEBUG( |
|
258 m_am_tools, |
|
259 TRACE_FLAGS_DEFAULT, |
|
260 (EAPL("<<< %s <<<\n"), m_string)); |
|
261 } |
|
262 |
|
263 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
264 } |
|
265 |
|
266 /** |
|
267 * The constructor sets the values for the member variables |
|
268 */ |
|
269 eap_automatic_trace_string_c( |
|
270 abs_eap_am_tools_c * const tools, |
|
271 eap_format_string string) |
|
272 : m_am_tools(tools) |
|
273 , m_string(string) |
|
274 { |
|
275 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
276 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
277 } |
|
278 }; |
|
279 |
|
280 |
|
281 #endif //#if !defined(_EAP_AUTOMATIC_VARIABLE_H_) |
|
282 |
|
283 |
|
284 //-------------------------------------------------- |
|
285 |
|
286 |
|
287 |
|
288 // End. |