3D PLM Enterprise Architecture |
Middleware Abstraction - Object Modeler |
Using OM-derivationFactorizing and reusing code |
Use Case |
AbstractThis article shows how to create a component that OM-derives from another one, and how to use them in a client application. |
This use case is intended to show you how to create a component [1] [2] that OM-derives [3] from another one, and how to use them in a client application [4].
[Top]
CAASysDerivationOM is a set of use cases of the CAASystem.edu framework that illustrates CATIA System framework capabilities.
[Top]
This use case creates two components:
The class diagram is as follows:
CAASysSurface OM-derives and C++-derives from CATBaseUnknown. CAASysRevolSurface OM-derives and C++-derives from CAASysSurface. All the extension classes derive from CATBaseUnknown. OM-inheritance makes no sense for them.
[Top]
To launch CAASysDerivationOM, you will need to set up the build time environment, then compile CAASysDerivationOM along with its prerequisites, set up the run time environment, and then execute the use case [5].
[Top]
The CAASysDerivationOM use case is made of several classes located in the CAASysDerivationOM.m module of the CAASystem.edu framework:
Windows | InstallRootDirectory\CAASystem.edu\CAASysDerivationOM.m\ |
Unix | InstallRootDirectory/CAASystem.edu/CAASysDerivationOM.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
To create a component that OM-derives from another one, there are three main steps:
# | Step | Where |
---|---|---|
1 | Create the CAASysSurface Base Component | CAASysSurface class |
2 | Create the CAASysRevolSurface component that OM-derives from CAASysSurface | CAASysRevolSurface class |
3 | Take advantage of the OM-derivation in a client application | Client application |
[Top]
A component is made of a main class, and possibly of extension classes. The
component name is the main class name. A class is designated as a
component main class thanks to the CATDeclareClass
macro in the
class header file, and to the CATImplementClass
macro in the class
source file with the Implementation
keyword as second parameter.
The CAASysSurface class header file is as follows:
... #include "CATBaseUnknown.h" class CAASysSurface : public CATBaseUnknown { CATDeclareClass; public: CAASysSurface(); virtual ~CAASysSurface(); private: CAASysSurface(const CAASysSurface &iObjectToCopy); }; |
The CATDeclareClass
macro declares that the class CAASysSurface
belongs to a component. Note that the copy constructor is set as private. Let's
have a look at the class source file:
#include "CAASysSurface.h" CATImplementClass(CAASysSurface, Implementation, CATBaseUnknown, CATNull); CAASysSurface::CAASysSurface() {} CAASysSurface::~CAASysSurface() {} |
The CATImplementClass
macro declares that the CAASysSurface
class is a component main class thanks to the Implementation
keyword, that OM-derives from CATBaseUnknown. Note that the copy
constructor is not implemented. A copy constructor declared as private and not
implemented prevents the compiler to create a public one that client application
could use without your agreement.
This class has two extension classes that implement interfaces. The header
files of these classes also include the CATDeclareClass
macro.
Their source files include the CATImplementClass
macro with the
following parameters, for example for the CAAESysSurfaceArea class:
... CATImplementClass(CAAESysSurfaceArea, DataExtension, CATBaseUnknown, CAASysSurface); ... |
The CATImplementClass
macro declares that the CAAESysSurfaceArea
class is a data extension of the component whose main class is CAASysSurface.
Like for any extension class, its third parameter must always be CATBaseUnknown,
since OM-inheritance doesn't make sense for extensions. The two extension
classes implement interfaces as usual.
[Top]
Like for any component, the CAASysRevolSurface component main class
header file includes the CATDeclareClass
macro. Its source file
includes the CATImplementClass
macro with the following parameters:
... CATImplementClass(CAASysRevolSurface, Implementation, CAASysSurface, CATNull); ... |
The CATImplementClass
macro declares that the CAASysRevolSurface
class is a component main class thanks to the Implementation
keyword, that OM-derives from CAASysSurface component. Two extension
classes of this component implement interfaces as usual.
[Top]
The OM-derivation, or OM-inheritance, depending from where you look, enables client applications to ask for a pointer to an interface that the OM-derived component doesn't implement itself, but that one of its base components implements. For example, from a pointer to CAAISysRevolSurfaceAxis that the CAASysRevolSurface component itself implements, the client application can ask for a pointer to CAAISysSurfaceProperties implemented by its base component CAASysSurface, although there is no C++ inheritance links between the extension classes that make up the components, since all extension classes C++-derive from CATBaseUnknown. This can be shown using the following code:
... CAAISysSurfaceProperties * pCAAISysSurfaceProperties = NULL; HRESULT rc; rc = pCAAISysRevolAxis->QueryInterface(IID_CAAISysSurfaceProperties, (void**)&pCAAISysSurfaceProperties); if (SUCCEEDED(rc) ... |
Assume pCAAISysRevolAxis
is a valid pointer to CAAISysRevolSurfaceAxis
on the CAASysRevolSurface component. QueryInterface
returns
a valid pointer to CAAISysSurfaceProperties, although the CAASysRevolSurface
component doesn't implement it iself, but by means of its base component CAASysSurface.
[Top]
This use case shows how to create a component that OM-derives from another component, and how to use it in a client application.
[Top]
[1] | Creating Components |
[2] | Creating Interfaces |
[3] | Object Modeler Component and Implementation Inheritance |
[4] | Using Components |
[5] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Mar 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.