18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

THE MICROSOFT COMPONENT OBJECT MODEL<br />

All ActiveX controls support IDispatch. This means it is possible to use the various<br />

ActiveX controls shipped with ArcObjects to access functionality from<br />

within scripting environments.<br />

Interfaces that directly inherit from an interface<br />

other than IUnknown cannot be implemented<br />

in VB.<br />

COM<br />

containment<br />

COM<br />

aggregation<br />

Custom<br />

feature<br />

interface1<br />

interface2<br />

child class<br />

parent class<br />

interface1<br />

interface2<br />

interface1<br />

interface2<br />

interface3<br />

interface4<br />

IUnknown<br />

class<br />

method3<br />

method4<br />

IUnknown<br />

class<br />

method1<br />

method2<br />

IUnknown (controlling)<br />

class<br />

IUnknown (inner)<br />

class<br />

method1<br />

method2<br />

method3<br />

method4<br />

IUnknown<br />

feature<br />

method7<br />

method8<br />

IUnknown<br />

class<br />

method3<br />

method4<br />

method1<br />

method2<br />

method5<br />

method6<br />

INTERFACE INHERITANCE<br />

An interface consists of a group of methods and properties. If one interface<br />

inherits from another, then all the methods and properties in the parent are<br />

directly available in the inheriting object.<br />

The underlying principle here is interface inheritance, rather than the implementation<br />

inheritance you may have seen in languages such as SmallTalk and C++. In<br />

implementation inheritance, an object inherits actual code from its parent; in<br />

interface inheritance, it’s the definitions of the methods of the object that are<br />

passed on. The coclass that implements the interfaces must provide the implementation<br />

for all inherited interfaces.<br />

Implementation inheritance is not supported in a heterogeneous development<br />

environment because of the need to access source and header files. For reuse of<br />

code, COM uses the principles of aggregation and containment. Both of these are<br />

binary-reuse techniques.<br />

AGGREGATION AND CONTAINMENT<br />

For a third-party developer to make use of existing objects, using either containment<br />

or aggregation, the only requirement is that the server housing the contained<br />

or aggregated object is installed on both the developer and target release machines.<br />

Not all development languages support aggregation.<br />

The simplest form of binary reuse is containment. Containment allows modification<br />

of the original object’s method behavior but not the method’s signature.<br />

With containment, the contained object (inner) has no knowledge that it is<br />

contained within another object (outer). The outer object must implement all the<br />

interfaces supported by the inner. When requests are made on these interfaces,<br />

the outer object simply delegates them to the inner. To support new functionality,<br />

the outer object can either implement one of the interfaces without passing the<br />

calls on or implement an entirely new interface in addition to those interfaces<br />

from the inner object.<br />

COM aggregation involves an outer object that controls which interfaces it<br />

chooses to expose from an inner object. Aggregation does not allow modification<br />

of the original object’s method behavior. The inner object is aware that it is being<br />

aggregated into another object and forwards any QueryInterface calls to the outer<br />

(controlling) object so the object as a whole obeys the laws of COM.<br />

To the clients of an object using aggregation, there is no way to distinguish which<br />

interfaces the outer object implements and which interfaces the inner object<br />

implements.<br />

Custom features make use of both containment and aggregation. The developer<br />

aggregates the interfaces where no customizations are required and contains those<br />

that are to be customized. The individual methods on the contained interfaces can<br />

then either be implemented in the customized class, thus providing custom functionality,<br />

or the method call can be passed to the appropriate method on the contained<br />

interface.<br />

66 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!