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 |
|
19 #ifndef STSCOMMON_H |
|
20 #define STSCOMMON_H |
|
21 |
|
22 // Enables pushing a call to ResetAndDestroy into cleanup stack |
|
23 |
|
24 template<class T> |
|
25 class CleanupResetAndDestroy |
|
26 { |
|
27 public: |
|
28 inline static void PushL(T& aRef); |
|
29 private: |
|
30 static void ResetAndDestroy(TAny *aPtr); |
|
31 }; |
|
32 template<class T> |
|
33 inline void CleanupResetAndDestroyPushL(T& aRef); |
|
34 template<class T> |
|
35 inline void CleanupResetAndDestroy<T>::PushL(T& aRef) |
|
36 { |
|
37 CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &aRef)); |
|
38 } |
|
39 template<class T> |
|
40 void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr) |
|
41 { |
|
42 (STATIC_CAST(T*,aPtr))->ResetAndDestroy(); |
|
43 } |
|
44 template<class T> |
|
45 inline void CleanupResetAndDestroyPushL(T& aRef) |
|
46 { |
|
47 CleanupResetAndDestroy<T>::PushL(aRef); |
|
48 } |
|
49 |
|
50 #endif // STSCOMMON_H |