|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 // apacln.h |
|
16 // |
|
17 |
|
18 |
|
19 #ifndef __APACLN_H__ |
|
20 #define __APACLN_H__ |
|
21 |
|
22 #include <apparc.h> |
|
23 |
|
24 /** Allows CApaDocument-derived objects to be safely put onto the cleanup |
|
25 stack, by calling CApaProcess::DestroyDocument() should a leave or a call |
|
26 to CleanupStack::PopAndDestroy() occur. |
|
27 |
|
28 It is used as follows. |
|
29 @code |
|
30 TApaDocCleanupItem cleanup(iEikonEnv->Process(),doc); |
|
31 CleanupStack::PushL(cleanup); |
|
32 // some potentially leaving code here ... |
|
33 CleanupStack::Pop(cleanup); |
|
34 @endcode |
|
35 @publishedPartner |
|
36 @deprecated |
|
37 */ |
|
38 class TApaDocCleanupItem |
|
39 { |
|
40 public: |
|
41 inline TApaDocCleanupItem(CApaProcess* aProcess,CApaDocument* aDoc); |
|
42 inline operator TCleanupItem(); |
|
43 private: |
|
44 IMPORT_C static void DoCleanup(TAny* aPtr); |
|
45 public: |
|
46 /** The process object that will be used to destroy the document. */ |
|
47 CApaProcess* iApaProcess; |
|
48 /** The document to destroy as part of cleanup. */ |
|
49 CApaDocument* iApaDoc; |
|
50 }; |
|
51 |
|
52 |
|
53 /** Constructs a cleanup item object for the specified document. |
|
54 |
|
55 @param aProcess A pointer to the process object that will be used to destroy the document. |
|
56 @param aDoc The document to destroy as part of cleanup. */ |
|
57 inline TApaDocCleanupItem::TApaDocCleanupItem(CApaProcess* aProcess,CApaDocument* aDoc) |
|
58 : iApaProcess(aProcess), iApaDoc(aDoc) |
|
59 {} |
|
60 |
|
61 /** A TCleanupItem cast operator that enables the TApaDocCleanupItem object to be pushed to |
|
62 the cleanup stack as a TCleanupItem, so that the document will be properly destroyed |
|
63 (by a call to CApaProcess::DestroyDocument()) should a leave or a call to |
|
64 CleanupStack::PopAndDestroy() occur. */ |
|
65 inline TApaDocCleanupItem::operator TCleanupItem() |
|
66 {return TCleanupItem(DoCleanup,this);} |
|
67 |
|
68 #endif // __APACLN_H__ |