Symbian3/SDK/Source/GUID-A18153C0-230C-51FB-9384-A48BB4E42F03.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-A18153C0-230C-51FB-9384-A48BB4E42F03" xml:lang="en"><title>Cleanup
Strategy</title><shortdesc>The support for custom cleanup strategies is based on a template-based
implementation of the Strategy design pattern. Cleanup strategies can be specified
as an optional template parameter of the class templates for automatic resource
management. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section><title>Default Cleanup Strategy </title> <p>The default cleanup strategy
is determined by the <xref href="GUID-72BC7E43-1ABA-334A-B8ED-F9A152505FE6.dita"><apiname>TResourceCleanupStrategy</apiname></xref> class template
which by default calls a function named <xref href="GUID-78FEE338-1BD4-360B-93E2-80FD2753396D.dita"><apiname>Cleanup()</apiname></xref> function.
The <xref href="GUID-CE0F22BA-8789-3659-87C4-164EB5862B4C.dita"><apiname>DEFINE_CLEANUP_FUNCTION</apiname></xref> macro defines an inline function
named Cleanup() function which is invoked for cleanup of the managed object
in place of the default CallCleanupFunction function defined in the header
file. </p> </section>
<section><title>DEFINE_CLEANUP_FUNCTION Macro</title> <p> <xref href="GUID-CE0F22BA-8789-3659-87C4-164EB5862B4C.dita"><apiname>DEFINE_CLEANUP_FUNCTION</apiname></xref> is
provided in order to enable Symbian Developers to easily define the default
cleanup member function for a class type, such as an R-class. The macro can
be used in the same namespace in which the R-class is defined or in a namespace
in which the R-class is used. The DEFINE_CLEANUP_FUNCTION can be used by class
designers, but if a class does not have a cleanup function specified, then
the class users can use the DEFINE_CLEANUP_FUNCTION in order to define the
default cleanup function for that class. </p> </section>
<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>.
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>
</conbody><related-links>
<link href="GUID-3799F0DA-B99C-55BB-B44F-63B971DF1865.dita"><linktext>Cleanup Strategy
Tutorial</linktext></link>
</related-links></concept>