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.

CLASSES AND RELATIONSHIPS<br />

There are three types of classes shown in the UML diagrams: abstract classes,<br />

coclasses, and classes.<br />

abstract<br />

class<br />

Instantiation<br />

Type<br />

inheritance<br />

coclass<br />

Composition<br />

class<br />

Association<br />

1..*<br />

Multiplicity<br />

A coclass represents objects that you can directly create using the object declaration<br />

syntax in your development environment. In Visual Basic, this is written<br />

with the Dim pFoo As New FooObject syntax.<br />

Dim pWSName as iworkspacename<br />

Set pwsname = new workspacename<br />

Dim pPoint as iPoint<br />

Set pPoint = new Point<br />

'Declare the interface you will use to<br />

access the object<br />

'Creates a new instance of the<br />

WorkSpaceName class<br />

The example discussed here—primary and<br />

secondary line classes that each meet the<br />

specification of the abstract line class—is an<br />

illustration of type inheritance. Type inheritance<br />

is discussed in detail later in this appendix.<br />

To keep the object model diagrams as simple<br />

and usable as possible, only key relationships, or<br />

associations, are shown.<br />

Dim pGeometry as iGeometry<br />

Set pGeometry = new Point<br />

A class can’t directly create new objects, but objects of a class can be created as a<br />

property of another class or by functions from another class.<br />

Dim pName as IName<br />

Dim pFeatClass As IFeatureClass<br />

Set pFeatClass = pName.Open<br />

An abstract class can’t be used to create new objects; it is a specification for subclasses.<br />

An example is that a “line” could be an abstract class for “primary line”<br />

and “secondary line” classes. Abstract classes are important for developers who<br />

want to create a subclass of their own; they show which interfaces are required<br />

and which are optional for the type of class they are implementing. Required<br />

interfaces must be implemented on any subclass of the abstract class to ensure the<br />

new class behaves correctly in the ArcObjects system.<br />

Dim pGeometry as IGeometry<br />

Set pGeometry = New Point<br />

If typeof pGeometry is IGeometry the<br />

Msgbox "This is a Geometry object"<br />

End if<br />

RELATIONSHIPS<br />

Among abstract classes, coclasses, and classes, there are several types of class<br />

relationships possible—associations, type inheritance, instantiation, composition,<br />

and n-ary associations.<br />

Associations<br />

Associations represent relationships between classes. They have defined multiplicities<br />

at both ends.<br />

Appendix A • Reading the object model diagrams • 443

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

Saved successfully!

Ooh no, something went wrong!