--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/PDK/Source/GUID-F94CEC6D-C602-550F-9B12-856493F3C509.dita Fri Jan 22 18:26:19 2010 +0000
@@ -0,0 +1,60 @@
+<?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 task
+ PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
+<task xml:lang="en" id="GUID-F94CEC6D-C602-550F-9B12-856493F3C509"><title>Implementing an Interface </title><shortdesc>An interface implementation is a single unit of functionality that is instantiated through the interface definition. An implementation is created by deriving a class from the interface definition, and implementing its functions. An interface implementation actually provides the services defined by the interface. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody><steps id="GUID-7A342564-DF90-57AD-874C-164C7BE66B9A"><step id="GUID-C213F154-EEA1-503B-A184-AB76FF1DECE2"><cmd>Derive a class from the interface definition. </cmd> </step> <step id="GUID-C72498E7-82F6-598F-A1D7-613A89E9D4A2"><cmd>Implement the object creation functions like <codeph>NewL()</codeph> or <codeph>ConstructL()</codeph> for the derived class. </cmd> </step> <step id="GUID-0C9777EC-5998-5A83-9C13-3E45875BB748"><cmd>Call the appropiate <xref href="GUID-1344F049-81C4-3D17-AF46-8B5584680ADB.dita#GUID-1344F049-81C4-3D17-AF46-8B5584680ADB/GUID-C7F147AC-6D77-3169-AAB4-B27262B4333B"><apiname>REComSession::CreateImplementationL()</apiname></xref> function to instantiate an interface implementation that satisfies the specified interface. </cmd> </step> <step id="GUID-6379343D-1990-59ED-919E-AEB7185C1A44"><cmd>Implement the pure virtual functions defined by the interface definition, to provide required services to clients. </cmd> </step> </steps> <example id="GUID-8CE792E8-0E17-5660-A1E0-DF10E83B73D4"><title>Creating an interface implementation example</title> <p>The following code depicts an example segment of the interface definition class derived from <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive</apiname></xref>. </p> <codeblock id="GUID-D988EFE2-4F4E-5A5A-B1E8-1859A3FB8198" xml:space="preserve">class CExampleInterfaceDefinition : public CActive
+ {
+public:
+ // Wraps ECom object instantiation
+ static CExampleInterfaceDefinition* NewL();
+ // Wraps ECom object destruction
+ virtual ~CExampleInterfaceDefinition();
+ // Interface service
+ virtual void DoMethodL() = 0;
+...
+private:
+ // Instance identifier key or UID.
+ TUid iDtor_ID_Key;
+ };</codeblock> <p>The following code depicts a class derived from the interface definition CExampleInterfaceDefinition. </p> <codeblock id="GUID-1F88C6F8-2486-5EDB-A7D3-0E15CB0C7633" xml:space="preserve">class CExampleIntImplementation : public CExampleInterfaceDefinition
+ {
+public:
+ // Two-phase constructor
+ static CExampleIntImplementation* NewL();
+ // Destructor
+ ~CExampleIntImplementation();
+ // Implement the required methods from CExampleInterfaceDefinition
+ void DoMethodL();
+
+private:
+ void ConstructL();
+ };</codeblock> <p>The following code depicts the implementation of the object creation functions and virtual functions in CExampleInterfaceDefinition. </p> <codeblock id="GUID-B1356DF4-C838-5DF8-AE43-5F503780E5DE" xml:space="preserve">CExampleIntImplementation* CExampleIntImplementation::NewL()
+{
+ CExampleIntImplementaion self = new (ELeave) CExampleIntImplmentation();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+}
+
+void CExampleIntImplementation::ConstructL()
+{
+// specific implementation
+}
+CExampleIntImplementation::~CExampleIntImplementation()
+{
+}
+ ~CExampleIntImplementation();
+
+void CExampleIntImplementation::DoMethodL()
+{
+ // specific implementation of the DoMetholdL()
+}
+
+</codeblock> </example> </taskbody></task>
\ No newline at end of file