3D PLM Enterprise Architecture |
Middleware Abstraction |
Using Lists of PointersCreating and managing lists of pointers |
Use Case |
AbstractThis article shows how to create and manage a list of pointers, illustrated by a list of pointers to the CAASysPoint class. |
This use case is intended to show you how to create and manage a list of pointers [1].
[Top]
CAASysCollections is a set of use cases of the CAASystem.edu framework that illustrates the collection management capabilities.
[Top]
This use case shows summarizes the collection management capabilities:
This article describes the list of pointer capabilities, taking a list of pointers to instances of the CAASysPoint class as example.
[Top]
To launch CAASysCollections, you will need to set up the build time environment, then compile CAASysCollections along with its prerequisites, set up the run time environment, and then execute the use case [2].
[Top]
The CAASysCollections use case is made of a several classes located in the CAASysCollections.m module of the CAASystem.edu framework:
Windows | InstallRootDirectory\CAASystem.edu\CAASysCollections.m\ |
Unix | InstallRootDirectory/CAASystem.edu/CAASysCollections.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
The following capabilities offered by lists of integers are described in the following steps:
# |
Step |
---|---|
1 | Create and fill in a list of pointers |
2 | Fill in a list of pointers |
3 | Locate a pointer |
4 | Remove pointers |
The CATSysPoint class used represents 2D points.
[Top]
A list of pointers to instances of the CATSysPoint class is created as a class using macros. The class header file named CAASysListOfSysPointPtr.h is as follows:
#ifndef CAASysListOfSysPointPtr_h #define CAASysListOfSysPointPtr_h #include "CAASysPoint.h" #include "CATLISTP_Clean.h" #include "CATLISTP_AllFunct.h" #include "CATLISTP_Declare.h" CATLISTP_DECLARE(CAASysPoint) #endif |
The CATLISTP_Clean.h file undefines all possible previously defined methods,
while the CATLISTP_AllFunct.h defines for the list class to create all the
available methods for list of pointer classes. The CATLISTP_DECLARE
macro creates the class header file.
The source file named CAASysListOfSysPointPtr.cpp is as follows:
#include "CAASysListOfSysPointPtr.h" #include "CATLISTP_Define.h" CATLISTP_DEFINE(CAASysPoint) |
The CATLISTP_DEFINE
macro creates the class source file. The
list of pointer to the CAASysPoint class is now created. Its name is CATLISTP(CAASysPoint).
[Top]
|
The CATLISTP(CAASysPoint) class is first instantiated, and then
instances of the CAASysPoint are created. Then the Append
method appends pointers to the created points to the list.
[Top]
... int indexP2 = lpCAASysPoint.Locate(&p2); cout << "L1.Locate(&p2) == " << indexP2 << endl; float xP2 = lpCAASysPoint[indexP2]->getX(); float yP2 = lpCAASysPoint[indexP2]->getY(); ... |
The Locate
method returns the rank of a given pointer in the
list. Note that this rank begins with 1. The located pointer can be used by
means of its rank in the list as if it where in an array, for example to get the
point x and y coordinates. This code provides the following output:
L1.Locate(&p2) == 3 |
[Top]
... lpCAASysPoint.RemoveValue(&p1); lpCAASysPoint.RemoveValue(&p3); ... |
The RemoveValue
method removes the pointer passed as parameter
from the list. The list now includes three pointers to points p0, p2, and p4.
[Top]
This use case shows how to create a class for a list a pointers to a given class, and how to use it.
[Top]
[1] | Lists of Pointers |
[2] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Mar 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.