| Online Eiffel Documentation

EiffelStudio

# Interfaces

COM interfaces have several facets. First, an interface is a deferred, or an abstract, class.This means that an interface is a specification of a type.Second, an interface pointer represents a COM object, which is callable by a clientapplication. An object can expose several interfaces, or represent several types.

## ECOM_INTERFACE

For each interface listed in a type library, the EiffelCOM wizard generates a deferred classand two effective classes: a proxy of an interface pointer, or a client side class, and a stubof an interface pointer, or a server side class. The deferred interface class inherits fromECOM_INTERFACEand has a deferred feature per each interface function. Both effective classes, or implementedinterfaces, inherit from the deferred class and implement its functions. The functions of theinterface proxy calls the underlying C layer, which in turn calls the COM component whilethe functions of the interface stub implement the component functionality.

ECOM_INTERFACEholds a pointer to the underlying COM interface.

## ECOM_QUERIABLE

Different languages handle type coercion in different ways. C uses type cast; C++ introducesseveral type casting mechanisms; Eiffel uses assignment attempt, etc. Every COM interface exposesthe QueryInterface function which allows clients to query the COMcomponent for a pointer to another interface. Querying a component for an interface pointer issimilar to using an assignment attempt in Eiffel. The Eiffel implementation of the assignmentattempt relies on the runtime data. Since changing the Eiffel runtime and theimplementation of the assignment attempt was not an option, EiffelCOM introduces a library classECOM_QUERIABLE, which has the creation routine

    			make_from_other (other: ECOM_INTERFACE)

which queries a COM component internally. Every interface proxy class inherits fromECOM_QUERIABLE.The one difference between this mechanism versus using assignment attempt is that upon failure anexception will be raised. An assignment attempt that fails simply returns Void.

## ECOM_STUB

ECOM_STUBinherits fromECOM_INTERFACE, and exposes the feature create_item which allows creating the underlying COM object.