equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CLEANUPRESETANDDESTROY_H__ |
|
21 #define __CLEANUPRESETANDDESTROY_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 // CLASS DEFINITION |
|
27 /** |
|
28 * Template class for cleaning up arrays that have a ResetAndDestroy() function. |
|
29 * To be used with the CleanupStack. |
|
30 */ |
|
31 template <class T> |
|
32 class MceCleanupResetAndDestroy |
|
33 { |
|
34 public: // New functions |
|
35 |
|
36 inline static void PushL( T& aRef ); |
|
37 |
|
38 private: // New functions |
|
39 |
|
40 static void ResetAndDestroy( TAny *aPtr ); |
|
41 |
|
42 }; |
|
43 |
|
44 // INLINE FUNCTIONS |
|
45 template <class T> |
|
46 inline void MceCleanupResetAndDestroy< T >::PushL( T& aRef ) |
|
47 { |
|
48 CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); |
|
49 } |
|
50 |
|
51 template <class T> |
|
52 void MceCleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr ) |
|
53 { ( static_cast< T* >( aPtr ) )->ResetAndDestroy(); } |
|
54 |
|
55 template <class T> |
|
56 inline void MceCleanupResetAndDestroyPushL( T& aRef ) |
|
57 { MceCleanupResetAndDestroy< T >::PushL( aRef ); } |
|
58 |
|
59 |
|
60 #endif // __CLEANUPRESETANDDESTROY_H__ |