COM interfaces have several facets. First, an interface is a deferred class ("abstract class" in C++ terms). This means that an interface is a specification of a type. Second, an interface pointer represents a COM object, which is callable by a client application. An object can expose several interfaces, or represent several types.

For each interface listed in a type library, the EiffelCOM wizard generates a deferred class and two effective classes: a proxy of an interface pointer, or a client side class, and a stub of an interface pointer, or a server side class. The deferred interface class inherits from ECOM_INTERFACE and has one deferred feature for each interface function. Both effective classes, or implemented interfaces, inherit from the deferred class and implement its functions. The functions of the interface proxy calls the underlying C layer, which in turn calls the COM component while the functions of the interface stub implement the component functionality.

ECOM_INTERFACE holds a pointer to the underlying COM interface.


Different languages handle type coercion or type narrowing in different ways. C uses type cast; C++ introduces several type casting mechanisms; Eiffel uses object test, etc. Every COM interface exposes the QueryInterface function which allows clients to query the COM component for a pointer to another interface. Querying a component for an interface pointer is analogous to using an object test in Eiffel. To accomplish this, EiffelCOM introduces a library class ECOM_QUERIABLE, which has the creation routine make_from_other (other: ECOM_INTERFACE)

which queries a COM component internally. Every interface proxy class inherits from ECOM_QUERIABLE. An important difference between this mechanism and using an object test is that if the creation routine fails to initialize a new ECOM_QUERIABLE object, an exception will be raised, whereas, the attached syntax of the object test will merely produce a False result in the case in which no object of the desired type is available.


ECOM_STUB inherits from ECOM_INTERFACE, and exposes the feature create_item which allows creating the underlying COM object.

cached: 02/27/2017 12:59:20.000 PM