Symbian3/SDK/Source/GUID-38C37BA5-B972-5C8B-B8DE-B2FECF2A3C3C.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 xml:lang="en" id="GUID-38C37BA5-B972-5C8B-B8DE-B2FECF2A3C3C"><title>Single Phase Constructor</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Single phase constructor is to push a pointer to the clean-up stack, and then complete its construction. It uses the macro <xref href="GUID-8BB41BAD-5ED4-32E5-B4B4-312E472297CB.dita"><apiname>CONSTRUCTORS_MAY_LEAVE</apiname></xref> that is necessary to ensure whether the cleanup is correctly handled in the event that a constructor may leave beneath a call to new(ELeave). </p> <example><title>Characteristics of single phase constructor</title> <p>The following are the major characteristics of single phase constructor: </p> <ul><li id="GUID-2682874E-E2C1-5985-A1E5-0C802889575B"><p>The implementation of NewL becomes much simpler </p> </li> <li id="GUID-CDFDB865-4BCA-59E5-9E20-60591E04027B"><p>By using RAII classes in fields to manage owned resources, constructor exception-safety can be maintained </p> </li> <li id="GUID-765D89CC-8B72-5A11-8392-82861D056A30"><p>Cleanup stack technology </p> </li> </ul> </example> <section><title>Example</title> <p>The following code snippet implies the usage of single phase constructor using <xref href="GUID-8BB41BAD-5ED4-32E5-B4B4-312E472297CB.dita"><apiname>CONSTRUCTORS_MAY_LEAVE</apiname></xref> macro. </p> <codeblock id="GUID-7A76F800-7980-58A0-9DCA-95502E8D4F3E" xml:space="preserve">
        class CManagedUserSinglePhase : public CBase
            {
            public:
            CONSTRUCTORS_MAY_LEAVE
            static CManagedUserSinglePhase* NewL(CTicker* aTicker)
                {
                    return new(ELeave) CManagedUserSinglePhase(aTicker);
                }
            }
</codeblock> </section> <section><title>See Also</title> <p><xref href="GUID-B007634D-4D55-528A-8B85-6120C633AC8B.dita">EUser High Level Library Overview</xref>  </p> <p><xref href="GUID-D33EB877-CCCB-527B-8AFC-4A8385C55E78.dita">EUser High Level Library Tutorials</xref>  </p> </section> </conbody></concept>