3D PLM PPR Hub Open Gateway |
Feature Modeler |
Creating Features in an Applicative ContainerWorking with user data in a structured document |
Use Case |
AbstractThis article discusses the CAAOsmAppliCont use case. This use case explains how to create user data in the form of features within an applicative container in a structured standard-type document. |
This use case is intended to help you understand how to integrate new features in an applicative container within a structured standard-type document such as a Part or Product document.
In order to create user data in a structured standard-type document, it is recommended that you use the feature modeler. Two different cases are possible:
In the first case, the following steps are necessary:
CATfct
" catalog using the CreateCatalog
method of CATCatalogFactoryServices, as shown in the CAAOsmCatalogSU
use case [1]OpenPrereqCatalog
method in order to open
the catalog containing the deriving StartUp.CreateStartUpInCatalog
method of CATICatalog, passing in the "supertype" parameter
the type of the deriving StartUp found in the existing catalog.Instanciate
method of CATISpecObject.In the second case, the following steps are necessary:
CATCreateApplicativeContainer
global functionRetrieveSU
method of CATICatalogInstanciate
method of CATISpecObjectCATGetApplicativeContainer
global function in order to list its members using the ListMembers
method of CATIClientContainer.This use case illustrates the second case only.
Before getting to the use case itself, you should have a good understanding of what a feature object is and how it is created [2].
[Top]
CAAOsmAppliCont is a use case of the CAAObjectSpecsModeler.edu framework that illustrates ObjectSpecsModeler framework capabilities.
[Top]
The goal of CAAOsmAppliCont is to illustrate working with user-defined features within a user-defined applicative container. It uses the "CAAOsmAdd" StartUp defined in the catalog created by the CAAOsmCatalogSU use case [1]. Here is an image of the contents of this catalog:
Note that the "CAAOsmAdd" StartUp has the feature type "CAAOsmAdd" and the client identification "CAAOsmClientId".
This use case also creates a new user-defined applicative container in which a new feature, instantiated from the "CAAOsmAdd" StartUp, will be stored. Here is an image of the contents of the new applicative container:
Note that in this example, the applicative container has a late
type of CATFeatCont
.
[Top]
To launch CAAOsmAppliCont, you will need to set up the build time environment, then compile CAAOsmAppliCont along with its prerequisites, set up the run time environment, and then execute the sample.
mkrun -c "CAAOsmAppliCont CAAOsmCatalogSU.CATfct DocumentStorageName.CATPart"
This is fully described in the referenced article [3]. When launching the use case, you must pass the following arguments:
[Top]
CAAOsmAppliCont code is located in the CAAOsmAppliCont.m use case module of the CAAObjectSpecsModeler.edu framework:
Windows | InstallRootDirectory\CAAObjectSpecsModeler.edu\CAAOsmAppliCont.m |
Unix | InstallRootDirectory/CAAObjectSpecsModeler.edu/CAAOsmAppliCont.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named CAAOsmAppliCont.cpp.
[Top]
There are ten logical steps in CAAOsmAppliCont:
We will now comment each of those sections by looking at the code.
[Top]
See the referenced article [4] for a detailed description of the steps to go through when creating a new document.
In this use case, we create a new "Part" document: CATDocument
*pDoc
, and retrieve its root container: CATIContainer *piRootContainer
.
[Top]
CATIdent idAppliCont = "CATFeatCont"; CATUnicodeString appliContIdentifier("CAAOsmAppliCont"); CATBaseUnknown *pApplicativeContainer = NULL; rc = ::CATCreateApplicativeContainer(&pApplicativeContainer, // appli cont created pDoc, // document idAppliCont, // type of appli cont IID_CATIContainer, // interface type of appli cont "", // supertype of appli cont appliContIdentifier); // name of appli cont ... CATIContainer *piApplicativeContainer = (CATIContainer*) pApplicativeContainer; |
To create a new applicative container, we use the CATCreateApplicativeContainer
global function. This function takes as arguments:
pApplicativeContainer
- the pointer that references the new
applicative container that is to be created. Its type can be a CATBaseUnknown,
a CATIContainer or a CATIClientContainer, depending on the
value of the fourth parameter.pDoc
- the CATDocument pointer to the current document
in which the applicative container will be createdidAppliCont
- if the value of this argument is not "CATFeatCont
",
the fifth parameter, the supertype, must be "CATFeatCont
".
This argument is the late type of the container that will be created.IID_CATIContainer
- the interface IID that this new
applicative container will implement. If a CATIClientContainer handle
were needed, this parameter would be: IID_CATIClientContainer.""
- this is the supertype of the
applicative container. If left blank, the idAppliCont
argument
must be "CATFeatCont
". Otherwise, this argument must
be "CATFeatCont
" itself.appliContIdentifier
- the name of this new applicative
container.Note that the new applicative container created must be of late type "CATFeatCont
"
or be of a late type deriving from "CATFeatCont
", as seen
in the fifth argument "supertype".
If the applicative container is created in an interactive command you must had the following line after the CATCreateApplicativeContainer call:
rc = ::CATOmbPerformAfterContainerCreation( piApplicativeContainer ); |
This method declares the container to the undo/redo mechanism. This call is usefull only in interactive context, once the undo/redo process is only an interactive feature.
Note: Always in interactive context, for an applicative container
implementing CATInit, the Init
method must be called after
the container creation, and the CATOmbPerformAfterContainerCreation
method must be called after the initialization.
[Top]
Loading the catalog means opening the catalog document and getting a CATICatalog handle that will be needed in order to retrieve StartUps from the catalog.
CATUnicodeString stgName = argv[1]; CATICatalog *piCatalog; CATUnicodeString clientId("CAAOsmClientId"); rc = ::AccessCatalog (&stgName, &clientId, piApplicativeContainer, &piCatalog); if (SUCCEEDED(rc)) cout << "Catalog accessed OK" << endl << flush; else { cout << "ERROR on AccessCatalog" << endl << flush; pApplicativeContainer -> Release(); return 6; } |
To open a catalog, use the AccessCatalog
global function that
takes the following arguments:
stgName
- the name of the catalog without the storage path
and with the .CATfct extension. The catalog must be found under the
"WS" + "OS" + resources + graphic directory.clientId
- the client id defined on the catalog at the time
of its creation.piApplicativeContainer
- a CATIContainer pointer to
the applicative container in which StartUps from the catalog will be
instantiated.piCatalog
- a CATICatalog pointer to the StartUps
catalog that has been opened.[Top]
CATBaseUnknown *pAddOpSU = NULL; CATUnicodeString addOpSUType("CAAOsmAdd"); rc = piCatalogOnContainer -> RetrieveSU(&pAddOpSU, &addOpSUType, "CATISpecObject"); piCatalogOnContainer -> Release(); piCatalogOnContainer = NULL; if (NULL != pAddOpSU) cout << "CAAOsmAdd StartUp retrieved OK" << endl << flush; else { cout << "ERROR in retrieving CAAOsmAdd StartUp" << endl << flush; pApplicativeContainer -> Release(); return 7; } // Get a CATISpecObject handle on the CAAOsmAdd StartUp CATISpecObject *piAddOpSU = (CATISpecObject*) pAddOpSU; |
A StartUp is retrieved from the catalog using the CATICatalog::RetrieveSU
method. This method returns a CATBaseUnknown pointer in pAddOpSU
which is directly cast into a CATISpecObject pointer (piAddOpSU
).
The CATBaseUnknown pAddOpSU
pointer must be released when no
longer needed.
[Top]
CATISpecObject *piAddOpInst1 = piAddOpSU -> Instanciate(CATUnicodeString("CAAOsmAdd1"), pApplicativeContainer); pAddOpSU -> Release(); pAddOpSU = NULL; pApplicativeContainer -> Release(); pApplicativeContainer = NULL; if (NULL != piAddOpInst1) cout << "CAAOsmAdd instance 1 created OK" << endl << flush; else { cout << "ERROR in creating instance 1 of CAAOsmAdd SU" << endl << flush; return 8; } piAddOpInst1 -> Release(); piAddOpInst1 = NULL; |
A new feature is created in the applicative container by instantiating the
StartUp that was retrieved from the catalog. This is done using the Instanciate
method of CATISpecObject. This method needs to know the new feature's
name and the container in which it will be created. Note that the CATBaseUnknown
pAddOpSU
pointer is released here since it will no longer be used.
[Top]
rc = CATDocumentServices::SaveAs (*pDoc, argv[2]); if (FAILED(rc)) { cout << "ERROR in saving document" << endl << flush; return 9; } rc = CATDocumentServices::Remove (*pDoc); if (FAILED(rc)) { cout << "ERROR in removing document" << endl << flush; return 10; } |
We save the new document under the name passed as a second argument to this
use case using the SaveAs
method of CATDocumentServices.
Then, we remove it from the session using the Remove
static method
of CATDocumentServices. Removing the document is necessary in this case
since we want to re-load it later on.
[Top]
rc = CATDocumentServices::Open(argv[2], pDoc); if (SUCCEEDED(rc) && (NULL != pDoc)) cout << "Document opened OK" << endl << flush; else { cout << "ERROR in opening an existing document" << endl << flush; return 11; } |
We re-load the document found under the same storage pathname as the one used
to save it. This is done in order to show the entire process of creating and
retrieving applicative containers within documents. In order to re-load the
document, we use the Open
static method of CATDocumentServices
which returns a CATDocument pointer to the document itself.
[Top]
rc = ::CATGetApplicativeContainer (&pApplicativeContainer, // appli cont retrieved pDoc, // document IID_CATIContainer, // interface type of appli cont appliContIdentifier); // name of appli cont to retrieve if (SUCCEEDED(rc)) cout << "Applicative container retrieved OK" << endl << flush; else { cout << "ERROR in retrieving applicative container" << endl << flush; return 12; } |
We use the CATGetApplicativeContainer
global function in order
to retrieve the applicative container created previously. We pass the following
arguments to this function:
pApplicativeContainer
- the pointer that references the
applicative container that we want to retrieve. Its type can be a CATBaseUnknown,
a CATIContainer or a CATIClientContainer, depending on the
value of the fourth parameter.pDoc
- the CATDocument pointer to the current document
in which the applicative container is to be foundIID_CATIContainer
- the interface IID that the applicative
container implements. If a CATIClientContainer handle were needed,
this parameter would be: IID_CATIClientContainer.appliContIdentifier
- the name given to the applicative
container when it was created.[Top]
CATIClientContainer *piClientOnAppliCont = NULL; rc = pApplicativeContainer -> QueryInterface(IID_CATIClientContainer, (void**) &piClientOnAppliCont); pApplicativeContainer -> Release(); pApplicativeContainer = NULL; if (NULL == piClientOnAppliCont) { cout << "ERROR in retrieving catalog pointer" << endl << flush; return 4; } CATListPtrCATBaseUnknown *pMemberList = new CATListPtrCATBaseUnknown(); rc = piClientOnAppliCont -> ListMembers(IID_CATISpecObject, // filter on object type clientId, // filter on client id of object &pMemberList); // list of objects retrieved piClientOnAppliCont -> Release(); piClientOnAppliCont = NULL; if (SUCCEEDED(rc)) cout << "Member list retrieved OK" << endl << flush; else { cout << "ERROR in retrieving member list" << endl << flush; return 13; } cout << "Number of members in applicative container: " << pMemberList->Size() << endl << flush; delete pMemberList; pMemberList = NULL; |
In order to retrieve the contents of an applicative container, we use the ListMembers
method of CATIClientContainer. First, we need a CATIClientContainer
handle on the applicative container itself. The ListMembers
method
takes the following arguments:
IID_CATISpecObject
- the interface IID that the objects to be
retrieved within the applicative container implementclientID
- the client identification defined on the catalog
whose StartUps served to instantiate the features to be retrieved from the
applicative containerpMemberList
- a CATListPtrCATBaseUnknown pointer that
will reference the list of the members of the applicative container.[Top]
See the referenced article [4] for a detailed description of the steps to go through when saving the document.
Note that the catalog document does not need to be removed from the session.
[Top]
This use case has demonstrated how to create an applicative container within a structured standard-type document and how to instantiate new features within it. Specifically, it has illustrated:
CATCreateApplicativeContainer
global functionAccessCatalog
global functionRetrieveSU
method of CATICatalogInstanciate
method of CATISpecObjectSaveAs
and Remove
static methods of CATDocumentServicesCATGetApplicativeContainer
global functionListMembers
method of CATIClientContainer[Top]
[1] | Creating StartUps in Catalogs |
[2] | Feature Modeler Conceptual Overview |
[3] | Building and Launching a CAA V5 Use Case |
[4] | Creating a New Document |
[Top] |
Version: 1 [May 2000] | Document created |
Version: 2 [Nov 2000] | Document modified |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.