Sunteți pe pagina 1din 11

How to Read ArcObjects Object Model Diagrams Eric Pimpler Introduction Anyone who has spent time working

with ArcObjects has no doubt stumbled across the concept of Object Model Diagrams (OMD). Object Model Diagrams are symbolic, visual illustrations that depict the relationships between classes, interfaces, methods, properties, and events. ArcObjects has an OMD that will help you understand the relationships between classes in its programming libraries. Conceptually there is only one OMD diagram in ArcObjects. However, since ArcObjects has been broken up into multiple libraries, each library contains a separate OMD. Object Model Diagrams serve as a roadmap for your programming tasks, and should be one of the first resources you use when tackling a programming task. In the figure below you will see an example of the visual nature of an Object Model Diagram.

Accessing the ArcObjects OMD The ArcObjects OMD for each programming library can be found in the ArcGIS Developer Help system under Library Reference. Each library contains an OMD that is stored in PDF format. Simply select the Object Model Diagram link to open the file. Each of the OMDs is also stored under the <installation directory>\ArcGIS\DeveloperKit\Diagrams\Desktop directory.

Object Model Diagram Symbology

Object Model Diagrams contain a number of symbols that represent various concepts. Lets take a look at the symbology that youre likely to encounter in an ArcObjects OMD and describe the meanings associated with these symbols. Classes In ArcObjects you will encounter three distinct types of classes: Abstract Classes, Instantiable Classes, and Creatable Classes (also called Co-Classes). The first class well discuss is Abstract Classes. In your ArcObjects OMDs these classes are represented by a 2D shaded rectangle with the class name in italics. These classes are not creatable or instantiable. They exist only to define general interfaces for subclasses that will inherit from these Abstract Classes. So, you can never create objects from this most basic type of class. In the figure below you will see the ArcObjects Layer class that is an Abstract Class that defines the general characteristics of a geographic layer. Notice that the class name is in italics and is enclosed by a 2D shaded rectangle.

The second type of class that we will discuss is Instantiable Classes. In your ArcObjects OMDs these symbols are represented as 3D rectangles with no shading. You can see an example of the instantiable Row class in the figure below. These classes are non-creatable classes in the sense that you cant use the New keyword to create a new object instance of these types of classes. Instead you obtain an object instance from other objects. In Visual Basic terms this means that we cant use the New keyword to create a new instance of this type of class. We must use other objects to derive an instance of this type of class. Notice that the symbology for the Row class (which is an Instantiable Class) is a 3D rectangle with no shading. The name of the class is not italicized.

The final type of class that you will encounter in ArcObjects is the Creatable Class (also called CoClass) that is defined in your ArcObjects OMDs as a shaded 3D rectangle. In the figure below, the Map class is a Createable Class. These classes differ from Instantiable classes in that you are allowed to use the New keyword to create new object instances from this type of class. In addition, object instances from these classes can be created from other objects just as they can with instantiable objects. Notice that the Map class is enclosed by a 3D shaded rectangle. The name of the class is not italicized

That covers the various types of classes that you will find in an ArcObjects OMD. Now lets turn our attention to some of the other symbols that you will find in an OMD. Interfaces ArcObjects is built on the COM standard which implies the use of Interfaces. Until you develop a good understanding of Interfaces you will struggle in your ArcObjects programming efforts. Interfaces are central to the use of ArcObjects and COM in general so you must spend the time to understand this crucial concept. I like to think of Interfaces as sub-classes within a larger class. They expose various characteristics and behaviors of a class through properties and methods. All ArcObjects classes contain one or more Interfaces. In the figure below we are highlighting the symbology of the ILayer Interface which is an Interface supported by the Layer class. Notice that an Interface is depicted with a Lollipop symbol. ILayer contains various properties (depicted by the barbell symbols) and methods (depicted by the arrow symbols). The Layer class also implements other Interfaces such as IGeoDataset, and IPublishLayer which are also depicted on the class diagram. Layer also implements the IPersist and IPersistStream Interfaces. Neither of these Interfaces is depicted on the class diagram. There are simply too many Interfaces in the ArcObjects OMDs to list the details of each so ESRI has detailed the most commonly used Interfaces of a class and simply made a note that there are additional Interfaces implemented by the class, but you must look elsewhere for the

details of the additional Interfaces. All access to the classes in ArcObjects occurs through these Interfaces and their properties and methods. One other point that we should make is that it is possible for an Interface to be implemented by more than one class. What this means is that you will see Interfaces on various classes.

Methods and Properties In addition to the OMD symbols that weve already covered a few additional symbols need to be covered. These symbols cover relationships defined on particular interfaces and include methods, properties, and events. Properties are represented by the Barbell symbol. Properties define the characteristics of an object and are typically represented by nouns. Properties can be: Read/Write

Read Only Write Only

Methods define the behaviors of an object and are typically represented by verbs. An arrow symbolically represents these behaviors.

An arrow also represents events, but the arrowhead is not filled in. Events are actions that are triggered by some type of external stimulus such as a button click or mouse move. Relationship Symbols There are a number of relationship symbols that you will find that define the relationships between the classes in an ArcObjects OMD. Lets briefly cover these symbols. The first relationship symbol well cover is the Type Of symbol. In the figure below, the SpatialFilter class is a type of QueryFilter. This indicates an inheritance relationship between a parent and child class. The parent class (in this case QueryFilter) defines characteristics (properties) and behaviors (methods) that are inherited by the child class (in this case SpatialFilter). Therefore, to carry out this example, since SpatialFilter is a Type Of QueryFilter, and is the child in the relationship, it has access to the Interfaces implemented by the parent.

The next type of relationship symbol that well cover is the Composed Of symbol. This symbol indicates that an object is composed of one or more objects. In the figure below, the MapDocument object is composed of a Map object and a PageLayout object.

The Creates or Instantiates symbol indicates that one class creates an instance of another class. In the figure below, not the dotted line with an arrow at the end that connects the Cursor class with the Row class. This indicates that a Cursor Creates or Instantiates an instance of a Row.

The Multiplicity symbol indicates that an object is composed of one or more other objects. In the figure below, note the multiplicity symbol attached to the solid arrow running between the Field and Fields object. This indicates that a Fields object is composed of one or more Field objects.

An Association symbol indicates that there is some type of association between two objects. Typically they have defined multiplicities at the ends of the lines. In the previous figure, the solid arrow represents an association between the Fields and Field objects. This simply indicates that the two objects are tied together in some way. Worm Holes The final symbol that well cover is the Worm Hole symbol. Worm Holes are used to indicate a connection to a different diagram. Conceptually there is only one ArcObjects OMD, but due to the size of the OMD it was necessary for ESRI to break the diagram up into smaller, functional diagrams. In the diagram below, the oval diagram surround the Map in ArcMap text indicates that the Layer class is associated with the Map class in the ArcMap OMD. It simply indicates that you need to refer to the ArcMap OMD for more information about the connection between the two classes.

S-ar putea să vă placă și