|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-A18153C0-230C-51FB-9384-A48BB4E42F03" xml:lang="en"><title>Cleanup |
|
13 Strategy</title><shortdesc>The support for custom cleanup strategies is based on a template-based |
|
14 implementation of the Strategy design pattern. Cleanup strategies can be specified |
|
15 as an optional template parameter of the class templates for automatic resource |
|
16 management. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
17 <section><title>Default Cleanup Strategy </title> <p>The default cleanup strategy |
|
18 is determined by the <xref href="GUID-72BC7E43-1ABA-334A-B8ED-F9A152505FE6.dita"><apiname>TResourceCleanupStrategy</apiname></xref> class template |
|
19 which by default calls a function named <xref href="GUID-78FEE338-1BD4-360B-93E2-80FD2753396D.dita"><apiname>Cleanup()</apiname></xref> function. |
|
20 The <xref href="GUID-CE0F22BA-8789-3659-87C4-164EB5862B4C.dita"><apiname>DEFINE_CLEANUP_FUNCTION</apiname></xref> macro defines an inline function |
|
21 named Cleanup() function which is invoked for cleanup of the managed object |
|
22 in place of the default CallCleanupFunction function defined in the header |
|
23 file. </p> </section> |
|
24 <section><title>DEFINE_CLEANUP_FUNCTION Macro</title> <p> <xref href="GUID-CE0F22BA-8789-3659-87C4-164EB5862B4C.dita"><apiname>DEFINE_CLEANUP_FUNCTION</apiname></xref> is |
|
25 provided in order to enable Symbian Developers to easily define the default |
|
26 cleanup member function for a class type, such as an R-class. The macro can |
|
27 be used in the same namespace in which the R-class is defined or in a namespace |
|
28 in which the R-class is used. The DEFINE_CLEANUP_FUNCTION can be used by class |
|
29 designers, but if a class does not have a cleanup function specified, then |
|
30 the class users can use the DEFINE_CLEANUP_FUNCTION in order to define the |
|
31 default cleanup function for that class. </p> </section> |
|
32 <example><title>Clean-up Strategy example</title> <codeblock id="GUID-4F8920C6-A073-503B-8DB0-74900745B47B" xml:space="preserve">DEFINE_CLEANUP_FUNCTION(RSimple, ReleaseData);</codeblock> <p>This sets the default cleanup behaviour for the RSimple class to be <xref href="GUID-343443A2-42F8-320E-A90C-5A7EA92F3C31.dita#GUID-343443A2-42F8-320E-A90C-5A7EA92F3C31/GUID-B87E7EAD-DCB3-3528-A74F-17887291F845"><apiname>RSimple::ReleaseData()</apiname></xref>. |
|
33 If this Macro is not used then the default cleanup behaviour would be to call <xref href="GUID-343443A2-42F8-320E-A90C-5A7EA92F3C31.dita#GUID-343443A2-42F8-320E-A90C-5A7EA92F3C31/GUID-08235146-9589-368E-B223-A2E464A2169B"><apiname>RSimple::Close()</apiname></xref>. </p> </example> |
|
34 </conbody><related-links> |
|
35 <link href="GUID-3799F0DA-B99C-55BB-B44F-63B971DF1865.dita"><linktext>Cleanup Strategy |
|
36 Tutorial</linktext></link> |
|
37 </related-links></concept> |