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