Symbian3/SDK/Source/GUID-6D6DFC3A-8940-531A-A319-922317D19B51.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     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-6D6DFC3A-8940-531A-A319-922317D19B51" xml:lang="en"><title>How to
       
    13 define the interface to a polymorphic interface DLL</title><shortdesc>Explains how to use a polymorphic interface DLL.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>The interface is defined by an abstract API which can be implemented by
       
    15 a DLL. The following code fragment defines the API in terms of a pure virtual
       
    16 abstract C++ class; this is an example class called <codeph>CMessenger</codeph>.</p>
       
    17 <codeblock id="GUID-68199E32-6801-5964-9B3E-56DAB3369E41" xml:space="preserve">class CMessenger : public CBase
       
    18     {
       
    19 public:
       
    20     virtual void ConstructL(CConsoleBase* aConsole, const TDesC&amp; aName)=0;
       
    21     virtual void ShowMessage()=0;
       
    22 private:
       
    23     CConsoleBase* iConsole;
       
    24     HBufC*        iName;
       
    25     };</codeblock>
       
    26 <codeblock id="GUID-039AF89C-AF41-5F69-AA47-8A0D66DBAAB7" xml:space="preserve">
       
    27 // The UID for Messenger DLLs.
       
    28 // The client imposes this on DLLs which satisfy the protocol.
       
    29 
       
    30 const TInt KMessengerUidValue=0x10004262;
       
    31 const TUid KMessengerUid={KMessengerUidValue};</codeblock>
       
    32 <p>The purpose of the example is to be able to issue a simple greeting message.
       
    33 Any number of DLLs can be created, each containing a different implementation
       
    34 of the class.</p>
       
    35 <section id="GUID-6C3A1A07-6140-4A41-9E83-8348CDC81222"><title>Notes:</title> <p>Because the API can be implemented differently
       
    36 in different DLLs, note the following when declaring the class:</p> <ul>
       
    37 <li id="GUID-2D946F12-48A1-57B0-ADE0-7BF143DE6A8A"><p>The constructor is not
       
    38 declared; the default C++ constructor is used, and is not exported from the
       
    39 DLL. Instead, a function is exported from the DLL which constructs an object
       
    40 of the concrete type using <codeph>new (ELeave)</codeph> semantics.</p> </li>
       
    41 <li id="GUID-302202A4-DB5A-5A75-B036-9E664A915809"><p>All functions are pure
       
    42 virtual; a DLL <i>must</i> provide an implementation for all such functions.</p> </li>
       
    43 <li id="GUID-61D75525-ACA5-5419-AB64-323A5BB0EAFD"><p>All functions are <codeph>public</codeph> since
       
    44 the published API is all there to be used, there is no need for <codeph>private</codeph> specifications.</p> </li>
       
    45 <li id="GUID-A8CF8455-8860-5C64-BA75-FD3880DD8619"><p>It is possible to use
       
    46 polymorphic interface DLLs in a more advanced way that allows some of these
       
    47 rules to be changed.</p> </li>
       
    48 </ul> </section>
       
    49 </conbody></concept>