Intel® Fortran Compiler 17.0 Developer Guide and Reference

Understanding COM Server Concepts (Windows*)

This topic only applies to Windows* operating systems.

The Fortran COM Server application wizard generates an initial Visual Studio project and creates a COM Hierarchy file, which describes the infrastructure of a COM server. You can modify this file with the COM Server Hierarchy Editor to define the implementation of one or more object classes, including its interface(s), and method(s).

When you save the hierarchy file, the Fortran source files are generated. You then need to write code to implement each method.

What Information You Need to Provide

When you create the COM Server project, you will need to describe the COM server classes that you want to implement.

A class implements one or more COM interfaces. In COM terminology, an interface is a semantically related set of functions. The interface as a whole represents a "feature", or set of related functionality, that is implemented by the class. An interface contains methods, otherwise known as member functions. A method is a routine that performs one of the actions that make up the feature. As far as the Fortran COM Server is concerned, methods are Fortran functions that take arguments and return a value like any other Fortran function.

Consider a simple example of a class that you will create using the Fortran COM Server Application Wizard, called AddingMachine. The class contains a single interface that we call IAdd. By convention, all interface names begin with a capital letter "I". You can define three methods in the IAdd interface:

These methods allow you to perform specific, distinct tasks with the IAdd interface from any language that supports a COM client. The Fortran COM Server Editor provides a user interface to enter this information about the class (in this case the AddingMachine class), which is discussed later in Creating the Fortran COM Server.

An interface can also contain properties. Properties are method pairs that set or return information about the state of an object. Properties must currently be implemented using the get_Method and put_Method and the same DISPID property.

In terms of the data associated with an object, a key concept of object-oriented programming is encapsulation. Encapsulation means that all of the details about how the object is implemented, including the data that it uses and the logic that it uses to perform its work, is hidden from the client. The client's only access to the object is through the interfaces that the object supports.

You need to define the data that the object uses and code the logic of the methods. For the data, the Fortran COM Server Application Wizard uses the model that each instance of the object has an associated instance of a Fortran derived-type. The code generated by the wizard takes care of creating and destroying the instances of the derived-type as objects are created and destroyed.

You define the fields of the derived-type. For example, with our AddingMachine, each AddingMachine object needs to store the current value. The derived-type associated with each AddingMachine object would contain a single field of type REAL. We name it CurrentValue. Note that each instance of the AddingMachine object has its own instance of the derived-type and its own CurrentValue. This means that the server could support multiple clients simultaneously and each client would see its own AddingMachine. That is, each client is unaffected by the existence of other clients. The derived-type associated with each object is discussed in detail in Creating the Fortran COM Server.

To summarize, at a high level, what you need to do to create a COM server:

What the COM Server Will Provide

The Fortran COM Server Editor generates source files that implement all of the infrastructure, or "plumbing", of the COM server. The generated files take care of such tasks as:

The majority of these source files are generated fully by the Fortran COM Server Editor and are not modified by you. Other files contain the skeleton or template of your derived-type and methods. You edit these Fortran source files to fill in your implementation. A walk-through of the AddingMachine example will show you how it's done.