3D PLM Enterprise Architecture |
Middleware Abstraction - Object Modeler |
Interface Quick ReferenceA step-by-step to create interfaces |
Quick Reference |
AbstractThis article gives you a step-by-step to create an interface. It includes the following sections: |
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]
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:
#ifndef CAAISysCollection_h #define CAAISysCollection_h ... #endif
These directives protect from file multiple inclusion
... #include "CATBaseUnknown.h" ...
... #include "CAASysGeoModelInf.h" ...
... extern ExportedByCAASysGeoModelInf IID IID_CAAISysCollection; ...
... class ExportedByCAASysGeoModelInf CAAISysCollection : public CATBaseUnknown { ...
CATDeclareClass
macro, always located before the public
keyword... CATDeclareClass; ...
HRESULT
[3]
... 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; }; ...
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]
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:
#include "CAAISysCollection.h" ...
... IID IID_CAAISysCollection = { /* 8d143952-d4bf-11d3-b7f5-0008c74fe8dd */ 0x8d143952, 0xd4bf, 0x11d3, {0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd} }; ...
CATImplementInterface
macro to make a CAA V5 interface
from this abstract class. The parameters of CATImplementInterface
are the interface name and the base interface name respectively
... CATImplementInterface(CAAISysCollection, CATBaseUnknown);
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]
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]
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]
[1] | CAA V5 Naming Conventions |
[2] | Trigrams for Frameworks |
[3] | What Is HRESULT? |
[4] | About Globally Unique IDentifiers |
[Top] |
Version: 1 [Jul 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.