|
1 /* |
|
2 * Copyright (c) 2009 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: Cleanup macros and definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef WIMCLEANUP_H |
|
19 #define WIMCLEANUP_H |
|
20 |
|
21 #include "wimi.h" |
|
22 |
|
23 |
|
24 // |
|
25 // CleanupStack functions for WIMI data |
|
26 // |
|
27 |
|
28 inline void CleanupPushWimBufL( WIMI_BinData_t& aWimData ) |
|
29 { |
|
30 CleanupStack::PushL( TCleanupItem( WSL_OS_Free, aWimData.pb_buf ) ); |
|
31 } |
|
32 |
|
33 inline void CleanupPushWimRefL( WIMI_Ref_t* aWimRef ) |
|
34 { |
|
35 CleanupStack::PushL( TCleanupItem( free_WIMI_Ref_t, aWimRef ) ); |
|
36 } |
|
37 |
|
38 void FreeRefList( void* aRefList ); |
|
39 |
|
40 inline void CleanupPushWimRefListL( WIMI_RefList_t aWimRefList ) |
|
41 { |
|
42 CleanupStack::PushL( TCleanupItem( FreeRefList, aWimRefList ) ); |
|
43 } |
|
44 |
|
45 |
|
46 // |
|
47 // CleanupResetAndDestroyPushL() function |
|
48 // |
|
49 |
|
50 template <class T> |
|
51 class CleanupResetAndDestroy |
|
52 { |
|
53 public: |
|
54 inline static void PushL( T& aRef ); |
|
55 private: |
|
56 static void ResetAndDestroy( TAny *aPtr ); |
|
57 }; |
|
58 |
|
59 template <class T> |
|
60 inline void CleanupResetAndDestroyPushL( T& aRef ); |
|
61 |
|
62 template <class T> |
|
63 inline void CleanupResetAndDestroy<T>::PushL( T& aRef ) |
|
64 { |
|
65 CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); |
|
66 } |
|
67 |
|
68 template <class T> |
|
69 void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr ) |
|
70 { |
|
71 if( aPtr ) |
|
72 { |
|
73 static_cast<T*>( aPtr )->ResetAndDestroy(); |
|
74 } |
|
75 } |
|
76 |
|
77 template <class T> |
|
78 inline void CleanupResetAndDestroyPushL( T& aRef ) |
|
79 { |
|
80 CleanupResetAndDestroy<T>::PushL( aRef ); |
|
81 } |
|
82 |
|
83 |
|
84 #endif // WIMCLEANUP_H |
|
85 |