3D PLM Enterprise Architecture

Middleware Abstraction - Object Modeler

Interface Quick Reference

A step-by-step to create interfaces
Quick Reference

Abstract

This article gives you a step-by-step to create an interface. It includes the following sections:


Choosing the Interface Name

Choose a significant name beginning with the trigram of your company, followed by I for Interface. For example, CATIA interface names begin with CATI, and sample interfaces for CAA begin with CAAI. This ensures unique interface names to enable coexistence for interfaces coming from different providers on your site, or on you customers' sites  [1].

You can add to this four-character prefix the trigram of the framework into which you intend to put the interface, providing you manage a list of unique trigrams for your frameworks [2]. This lets you manage unique interface names at the framework level. For example, sample interfaces of the CAASystem.edu framework, that illustrates the CATIA System framework, begin with CAAISys, where Sys is the trigram for the System framework.

[Top]

Creating the Interface Header File

Create the interface header file, such as CAAISysPoint.h. Since an interface is usually intended for clients, this header file should be placed in the PublicInterfaces directory of your framework. Insert in this file:

The header file is:

#ifndef CAAISysCollection_h
#define CAAISysCollection_h

#include "CATBaseUnknown.h"

#include "CAASysGeoModelInf.h"

extern ExportedByCAASysGeoModelInf IID IID_CAAISysCollection;

class ExportedByCAASysGeoModelInf CAAISysCollection : public CATBaseUnknown
{
  CATDeclareInterface;
  public:
    virtual HRESULT GetNumberOfObjects(int * oCount) = 0;
    virtual HRESULT GetObject    (int iRank,
                                  CATBaseUnknown ** oObject) = 0;
    virtual HRESULT AddObject    (CATBaseUnknown * iObject) = 0;
    virtual HRESULT RemoveObject (CATBaseUnknown * iObject) = 0;
    virtual HRESULT Empty  () =0 ;
};
#endif

[Top]

Creating the Interface Source File

Create the interface source file in the src directory of the module dedicated to interfaces of your framework, such as CAAISysCircle.cpp file, and insert in it:

The source file is:

#include "CAAISysCollection.h"

IID IID_CAAISysCollection = { /* 8d143952-d4bf-11d3-b7f5-0008c74fe8dd */
    0x8d143952,
    0xd4bf,
    0x11d3,
    {0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd}
  };

CATImplementInterface(CAAISysCollection, CATBaseUnknown);

[Top]

Creating the TIE File

Create the TIE file in the src directory of the module dedicated to interfaces of your framework, such as TIE_CAAISysCollection.tsrc, to request the code builder mkmk to generate the TIE associated with the interface. Because your clients do not need the TIE to retrieve a pointer to your interface thanks to QueryInterface and to call its methods, the TIE is created in the ProtectedGenerated directory by default.

#include "CAAISysCollection.h"

If the client must implement the interface, create the TIE in the PublicGenerated directory. The TIE file should then also include the //public keyword.

#include "CAAISysCollection.h"
//public

[Top]


In Short

Creating interfaces implies choosing a name appropriate for both interface easy identification and interface name uniqueness. Then you can create the interface header and source files. Last, the interface TIE file lets mkmk automatically create the interface TIE.

[Top]


References

[1] CAA V5 Naming Conventions
[2] Trigrams for Frameworks
[3] What Is HRESULT?
[4] About Globally Unique IDentifiers
[Top]

History

Version: 1 [Jul 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.