| ID | CS000835 | Creation date | February 28, 2008 |
| Platform | S60 3rd Edition, FP1 | Tested on devices | Nokia N95 |
| Category | Symbian C++ | Subcategory | Base/System |
| Keywords (APIs, classes, methods, functions): REComSession, TEComResolverParams |
This code snippet demonstrates how to implement an ECom component from the base class.
TARGET EComExample.dll
TARGETTYPE PLUGIN
...
UID 0x10009D8D 0xE01F5465
...
SOURCE Proxy.cpp
SOURCE CMyHelloEcom.cpp // Your ECom impl
...
// Import base class header and inline file
USERINCLUDE ..\interface
SYSTEMINCLUDE \epoc32\include
SYSTEMINCLUDE \epoc32\include\ecom
// ECom resource name must be identical to ECom component/DLL name.
START RESOURCE E01F5465.rss
TARGET EComExample.rsc
TARGETPATH \resource\plugins
END
The header file is derived from the ECom base class.
// Include base class header
#include <CHelloEcomIF.h>
class CMyHelloEcom : public CHelloEcomIF
{
public:
static CMyHelloEcom* NewL();
virtual ~CImplementationClassOne();
// Implementation of CHelloEcomIF
void SayHello(TDes& aString);
private:
CMyHelloEcom();
void ConstructL();
};
private:
HBufC* iDescriptor;
The class must implement the virtual method SayHello(TDes& aString) defined in the base class.
#include "CMyHelloEcom.h"
CMyHelloEcom* CMyHelloEcom::NewL()
{
CMyHelloEcom* self=new(ELeave) CMyHelloEcom();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
CMyHelloEcom::~CMyHelloEcom()
{
delete iDescriptor;
}
CMyHelloEcom::CMyHelloEcom()
{
}
void CMyHelloEcom::ConstructL()
{
}
// Implementation of CHelloEcomIF
void CMyHelloEcom::SayHello(TDes& aString)
{
aString.Copy(*iDescriptor);
}
The resource file describes the contents of your plug-in DLL. It defines IMPLEMENTATION_INFO for individual implementations. IMPLEMENTATION_INFO::implementation_uid is used by ECOM framework's default resolver to find the requested implementation for a client.
#include "RegistryInfo.rh"
RESOURCE REGISTRY_INFO theInfo
{
// UID for the DLL
dll_uid = 0xE01F5465;
// Declare an array of interface info
interfaces =
{
INTERFACE_INFO
{
// UID of the interface that is implemented
interface_uid = 0xE0009DC1;
implementations =
{
// Info for implementation of CHelloEcomIF
IMPLEMENTATION_INFO
{
implementation_uid = 0xE0009DC7;
version_no = 1;
display_name = "ecomexample";
opaque_data = "";
default_data = "ecomexample";
}
};
}
};
}
Defines where the implementations reside within the DLL. The ECom framework uses a chart of TImplementationProxy items to map implementation IDs to the locations of specific implementation instantiation methods (NewL). Each implementation ID within TImplementationProxy must match one in the resource file.
#include <e32std.h>
#include <ImplementationProxy.h>
#include "CMyHelloEcom.h"
// Maps the interface UIDs to implementation factory functions
const TImplementationProxy ImplementationTable[] =
{
IMPLEMENTATION_PROXY_ENTRY(0xE0009DC7, CMyHelloEcom::NewL)
};
// Exported proxy for instantiation method resolution
EXPORT_C const TImplementationProxy* ImplementationGroupProxy
(TInt& aTableCount)
{
aTableCount =
sizeof(ImplementationTable) / sizeof(TImplementationProxy);
return ImplementationTable;
}
The ECom interface has been implemented. The ECom component has a suitable resource file. Implementation factory functions have been defined in the "proxy".
No related wiki articles found