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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #if !defined(__APACLN_H__)
20 #if !defined(__APPARC_H__)
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.
30 It is used as follows.
32 TApaDocCleanupItem cleanup(iEikonEnv->Process(),doc);
33 CleanupStack::PushL(cleanup);
34 // some potentially leaving code here ...
35 CleanupStack::Pop(cleanup);
42 inline TApaDocCleanupItem(CApaProcess* aProcess,CApaDocument* aDoc);
43 inline operator TCleanupItem();
45 IMPORT_C static void DoCleanup(TAny* aPtr);
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;
54 inline TApaDocCleanupItem::TApaDocCleanupItem(CApaProcess* aProcess,CApaDocument* aDoc)
55 : iApaProcess(aProcess), iApaDoc(aDoc)
56 /** Constructs a cleanup item object for the specified document.
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. */
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);}