3D PLM Enterprise Architecture

Middleware Abstraction - Object Modeler

Implementing an Interface Using the BOA

Creating a data extension class that derives from the interface
Use Case

Abstract

This article shows how to create a CAA V5 data extension class that implements an interface using the BOA (Basic Object Adapter).


What You Will Learn With This Use Case

This use case is intended to show you how to create a CAA V5 component [1] with an extension class that implements an interface using the BOA [2].

[Top]

The CAASysComponentBOA Use Case

CAASysComponentBOA is a use case of the CAASystem.edu framework that illustrates the System framework capabilities.

[Top]

What Does CAASysComponentBOA Do

This use case includes the code for a V5 component made of a main implementation class, a data extension class that implements the sample CAAISysInterface, and a code extension class that implement the CATICreateInstance interface to enable the component to be instantiated thanks to the CATInstantiateComponent global function.

[Top]

How to Launch CAASysComponentBOA

You first need to build CAASysComponentBOA, CAASysInterface, and CAASysUseBOA. To do this, you will need to set up the build time environment, then compile CAASysComponentBOA, CAASysInterface, and CAASysUseBOA along with their prerequisites as described in [5]. Launch CAASysUseBOA that instantiate the component, calls QueryInterface to retrieve a CAAISysInterface pointer, calls its methods, deallocates, and returns.

[Top]

Where to Find the CAASysComponentBOA Code

The CAASysComponentBOA use case is made of several classes located in the CAASysComponentBOA.m for the component main classes and extension classes that implement CATICreateInstance, PublicInterfaces and CAASysInterface.m for the CAAISysInterface interface, and and CAASysUseBOA.m module for the main program. These modules belong to the CAASystem.edu framework:

Windows InstallRootDirectory\CAASystem.edu\
Unix InstallRootDirectory/CAASystem.edu/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

Only the BOA implementation is described. Creating an interface, and implementation class, and a code extension to implement CATICreateInstance can be found in [2], [3], and [4] respectively. To implement an interface using the BOA, there are three steps:

  1. Creating the Extension Class Header File
  2. Creating the Extension Class Source File
  3. Updating the Interface Dictionary

[Top]

Creating the Extension Class Header File

#include "CAAISysInterface.h"   //Needed to derive from CAAISysInterface

class CAAESysComponentBOA : public CAAISysInterface
{
  // Used in conjunction with CATImplementClass in the .cpp file
  CATDeclareClass;

  public:

    CAAESysComponentBOA();
    virtual ~CAAESysComponentBOA();

    // CAAISysInterface 
    // -------------------

    virtual HRESULT ToString();

  private:

    // Copy constructor, not implemented
    // Set as private to prevent from compiler automatic creation as public.
    CAAESysComponentBOA(const CAAESysComponentBOA &iObjectToCopy);

    // Assignment operator, not implemented
    // Set as private to prevent from compiler automatic creation as public.
    CAAESysComponentBOA & operator = (const CAAESysComponentBOA &iObjectToCopy);

};

The CAAESysComponentBOA class C++-derives from the interface it BOA-implement CATISysInterface. The CATDeclareClass macro declares that the class CAAESysComponentBOA belongs to a component. Note that the copy constructor and the assignment operator are set as private. This is very important for extensions. Since extensions must never be directly instantiated by client applications, this prevents the compiler from creating the copy constructor and the assignment operator as public without you know. These copy constructor andassignment operator are not implemented in the source file. The class has a constructor and a destructor, and the only method of CATISysInterface.

[Top]

Creating the Extension Class Source File

...
CATImplementClass(CAAESysComponentBOA, DataExtension, CAAISysInterface, CAASysComponentBOA);


//------------------------------------------------------------------------------------
// To declare that the class is a BOA
//
CATImplementBOA(CAAISysInterface,CAAESysComponentBOA);

CAAESysComponentBOA::CAAESysComponentBOA() 
{
  cout << "CAAESysComponentBOA::CAAESysComponentBOA" << endl;
}

//------------------------------------------------------------------------------------

CAAESysComponentBOA::~CAAESysComponentBOA()
{
  cout << "CAAESysComponentBOA::~CAAESysComponentBOA" << endl;
}

//------------------------------------------------------------------------------------

HRESULT CAAESysComponentBOA::ToString()
{
   cout << "CAAESysComponentBOA::ToString"<< endl; 
   return(S_OK);
}

The CATImplementClass macro declares that the CAAESysComponentBOA class is a component data extension class thanks the DataExtension keyword, OM-derives [6] from CAAISysInterface, and extends CAASysComponentBOA. Any data extension class that implements an interface using the BOA must OM-derive from the interface.

The CATImplementBOA macro declares that the CAAESysComponentBOA class implements the CAAISysInterface interface.

[Top]

Updating the Interface Dictionary

...
CAASysComponentBOA   CAAISysInterface  libCAASysComponentBOA
...

The interface dictionary declares that the CAASysComponentBOA component implements the CAAISysInterface interface and that the code to load into memory to use these interfaces is located in the libCAASysComponentBOA shared library or DLL. Note that the component main class name is used to refer to the component in the interface dictionary, and never the extension class name.

Top]


In Short

This use case shows how to create a data extension class that implements an interface using the BOA. The data extension class must C++-derive and OM-derive from the interface. This implies that a given data extension class can implement only one interface using the BOA to avoid multi inheritance. It may of course implement additional interfaces using TIEs.

[Top]


References

[1] Creating Components
[2] Creating Interfaces
[3] Creating a Component Factory
[4] Creating Components
[5] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Nov 2003] Document created
[Top]

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