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