|
||
A default resolver that selects an implementation to use is provided as part of ECom. If the algorithm used by that is inappropriate, an interface definition can provide its own custom resolver.
Custom resolvers are themselves interface implementations that implement
the ECom CResolver
interface. They are instantiated by
ECom as required, in response to
REComSession::CreateImplementationL()
calls that specify
to use a particular custom resolver. Custom resolvers must confirm to other
aspects of interface implementations, including providing registration resource
information, and publishing its UID and factory function in an implementation
proxy table.
A custom resolver class should derive from CResolver
and
implement:
a factory function that takes an MPublicRegistry
object. MPublicRegistry
provides the resolver with a list of the
implementations registered with ECom that satisfy a specified interface.
a IdentifyImplementationL()
function that takes
the UID of the interface for which an implementation is requested, and
resolution parameters to test against implementations, and returns the UID of
the best-fit implementation. The way in which "best-fit" is determined is of
course specific to each custom resolver.
a ListAllL()
function, which behaves in a
similiar way to IdentifyImplementationL()
, but which returns a
list of all matching implementations
Additionally, in order to be trusted by ECom, the plug-in should have the
ProtServ
capability set in its project file.
The following shows the public interface of an example custom resolver.
class CExampleResolver : public CResolver
{
public:
// Factory function:
static CExampleResolver* NewL(MPublicRegistry& aRegistry);
~CExampleResolver();
// Implement CResolver
TUid IdentifyImplementationL(TUid aInterfaceUid,
const TEComResolverParams& aParameters) const;
RImplInfoArray* ListAllL(TUid aInterfaceUid,
const TEComResolverParams& aParameters) const;
The following shows the registration resource required by a custom
resolver. The interface_uid
value is always 0x10009D90. Other UIDs
are specific to individual resolvers. The display_name
,
default_data
, and opaque_data
fields are unused.
RESOURCE REGISTRY_INFO theInfo
{
dll_uid = 0x10009DB3;
interfaces =
{
INTERFACE_INFO
{
interface_uid = 0x10009D90;
implementations =
{
IMPLEMENTATION_INFO
{
implementation_uid = 0x10009DB4;
version_no = 1;
display_name = "";
default_data = "";
opaque_data = "";
}
};
}
};
}