diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-6D6DFC3A-8940-531A-A319-922317D19B51.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-6D6DFC3A-8940-531A-A319-922317D19B51.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,49 @@ + + + + + +How to +define the interface to a polymorphic interface DLLExplains how to use a polymorphic interface DLL. +

The interface is defined by an abstract API which can be implemented by +a DLL. The following code fragment defines the API in terms of a pure virtual +abstract C++ class; this is an example class called CMessenger.

+class CMessenger : public CBase + { +public: + virtual void ConstructL(CConsoleBase* aConsole, const TDesC& aName)=0; + virtual void ShowMessage()=0; +private: + CConsoleBase* iConsole; + HBufC* iName; + }; + +// The UID for Messenger DLLs. +// The client imposes this on DLLs which satisfy the protocol. + +const TInt KMessengerUidValue=0x10004262; +const TUid KMessengerUid={KMessengerUidValue}; +

The purpose of the example is to be able to issue a simple greeting message. +Any number of DLLs can be created, each containing a different implementation +of the class.

+
Notes:

Because the API can be implemented differently +in different DLLs, note the following when declaring the class:

    +
  • The constructor is not +declared; the default C++ constructor is used, and is not exported from the +DLL. Instead, a function is exported from the DLL which constructs an object +of the concrete type using new (ELeave) semantics.

  • +
  • All functions are pure +virtual; a DLL must provide an implementation for all such functions.

  • +
  • All functions are public since +the published API is all there to be used, there is no need for private specifications.

  • +
  • It is possible to use +polymorphic interface DLLs in a more advanced way that allows some of these +rules to be changed.

  • +
+
\ No newline at end of file