Navigation:  Programming Cookbook > Creating COM Components > Dolphins COM Framework >


Previous pageReturn to chapter overviewNext page

The implementation of the server object itself (the coclass) will require one or more classes. Any Dolphin object can be a COM object, so existing classes can be extended to expose them as COM objects quite easily by the addition of a few methods required by the framework, and of course the implementations of the functions in the COM interface(s). The standard methods are required so that the framework can provide basic life-cycle management and QueryInterface support, and are defined by the <COMObject> protocol. These are:


Note that the <COMObject> protocol includes no reference count related messages, because life-cycle management is not the responsibility of the implementation classes but is provided as a generic capability of Dolphin’s COM framework (in fact by the COMObjectStub). The implementation of these messages is trivial (or empty) for all but #queryInterface:ifNone:, which is required to provide answer an interface pointer onto the server of the requested type if that interface is supported. There are example implementations of this in the image, such as in AXControlSite.

When starting from scratch one would normally subclass COMInterfaceImp as this allows one to inherit the majority of the <COMObject> implementation, in particular QueryInterface support, as well as generic self-registration code. To complete the template support one need then override only two methods:

1.COMInterfaceImp class>>clsid

#clsid answers the coclass CLSID (the globally unique ID allocated to the particular coclass which is registered with COM, and used by the client to “name” the object is wants to instantiate). One may also, optionally, override #progId to answer the friendly string name of the component which is sometimes used, for example. ‘Dolphin.RandomStream’. This is only needed for self-registration, however, and has no other use.

#supportedInterfaces is expected to answer an Array of the interface classes that the object implements, for example:


       ^Array with: IPropertyNotifySink


Consequently if one implements one’s COM server under COMInterfaceImp one can usually concentrate on its functionality without worrying too much about the plumbing.