equal
deleted
inserted
replaced
|
1 // ltkutils.inl |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 namespace LtkUtils |
|
13 { |
|
14 template <class T> |
|
15 class CleanupDestroy |
|
16 { |
|
17 public: |
|
18 inline static void PushL(T& aRef) { CleanupStack::PushL(TCleanupItem(&Destroy, &aRef)); } |
|
19 private: |
|
20 static void Destroy(TAny *aPtr) { static_cast<T*>(aPtr)->ResetAndDestroy(); } |
|
21 }; |
|
22 |
|
23 template <class T> |
|
24 class CleanupReset |
|
25 { |
|
26 public: |
|
27 inline static void PushL(T& aRef) { CleanupStack::PushL(TCleanupItem(&Reset, &aRef)); } |
|
28 private: |
|
29 static void Reset(TAny *aPtr) { static_cast<T*>(aPtr)->Reset(); } |
|
30 }; |
|
31 |
|
32 template <class T> |
|
33 inline void CleanupResetAndDestroyPushL(T& aRef) { CleanupDestroy<T>::PushL(aRef); } |
|
34 |
|
35 template <class T> |
|
36 inline void CleanupResetPushL(T& aRef) {CleanupReset<T>::PushL(aRef);} |
|
37 |
|
38 } |