External Interfaces/API    

Introducing MATLAB COM Integration

The Component Object Model, or COM, provides a framework for integrating reusable, binary software components into an application. Because components are implemented with compiled code, the source code may be written in any of the many programming languages that support COM. Upgrades to applications are simplified, as components can be simply swapped without the need to recompile the entire application. In addition, a component's location is transparent to the application, so components may be relocated to a separate process or even a remote system without having to modify the application.

Using COM, developers and end users can select application-specific components produced by different vendors and integrate them into a complete application solution. For example, a single application may require database access, mathematical analysis, and presentation-quality business graphs. Using COM, a developer may choose a database-access component by one vendor, a business graph component by another, and integrate these into a mathematical analysis package produced by yet a third.

This section covers:

Concepts and Terminology

Here are some terms that you should be familiar with when reading this chapter.

COM Objects

A COM object is an instance of a component object class, or component. COM enforces complete encapsulation of the object, preventing its data and implementation from being accessed directly. The methods of an object must be accessed through interfaces. (See "COM Interfaces", below).

COM objects operate either as in-process or out-of-process servers. When in-process, the objects are implemented in DLL files, and are loaded into the client application's address space. No interprocess communication is required. For out-of-process, the objects are in EXE files, and run in a separate server process and the application must communicate with them across process boundaries.

Objects may also reside on a remote system connected by a network. In this case, the Distributed Component Object Model, or DCOM, is used.

COM Interfaces

An interface provides access to the methods of a COM object. In fact, the only way to access a COM object is through an interface. Through certain methods (get and set), you also gain access to the object's properties. An interface does not contain any method implementation; it just serves as a pointer to the methods within the object.

Interfaces usually group a set of logically related methods together. An object may, and frequently does, expose (or make available) more than one interface. In order to use any COM object, you must learn about which interfaces it supports, and the methods, properties, and events implemented by the object. The COM object's vendor provides this information.

Automation

Automation is a simpler method of communication between COM clients and servers. It uses a single standard COM interface called IDispatch. This interface enables the client to find out about and invoke or access methods and properties supported by a COM object. A client and server that communicate using IDispatch are known as an Automation client and Automation server.

IDispatch is the only interface supported by MATLAB. Custom and dual interfaces are not supported.

Controls

A control is an Automation component that has a user interface, enabling it to respond to actions taken by the user. A window that has OK and Cancel buttons is an example of a control. A control runs in the process address space of its client application. The client, in this case, is said to be a control container since it contains the control.

Because a control communicates through Automation, the client application is able to directly invoke its methods and access its properties. The control must also be able to communicate back to the client. This enables it to notify the client application of an event occurence, such as a mouse click.


  COM and DDE Support Overview of MATLAB COM Support