3D PLM Enterprise Architecture

Middleware Abstraction

Using Lists of Values

Creating and managing lists of values
Use Case

Abstract

This article shows how to create and manage a list of values, illustrated by a list of values to the CAASysPoint class.


What You Will Learn With This Use Case

This use case is intended to show you how to create and manage a list of values.

[Top]

The CAASysCollections Case

CAASysCollections is a set of use cases of the CAASystem.edu framework that illustrates the collection management capabilities.

[Top]

What Does CAASysCollections Do

This use case shows summarizes the collection management capabilities:

This article describes the list of value capabilities, taking a list of values of the CAASysPoint class as example.

[Top]

How to Launch CAASysCollections

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 [1].

[Top]

Where to Find the CAASysCollections Code

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]

Step-by-Step

The following capabilities offered by lists of integers are described in the following steps:

#

Step

1 Create and fill in a list of values
2 Fill in a list of values
3 Locate a value
4 Remove values

The CATSysPoint class used represents 2D points.

[Top]

Creating a List of Values

A list of values to instances of the CATSysPoint class is created as a class using macros. The class header file named CAAListOfSysPointVal.h is as follows:

#ifndef CAAListOfSysPointVal_h
#define CAAListOfSysPointVal_h

#include  "CATLISTV_Clean.h"

#define	CATLISTV_Append
#define	CATLISTV_Locate
#define	CATLISTV_RemoveValue

#include  "CATLISTV_Declare.h"
CATLISTV_DECLARE(CAASysPoint)

#endif

The CATLISTV_Clean.h file undefines all possible previously defined methods. Only the Append, Locate, and RemoveValue methods are made available for the class. The CATLISTV_DECLARE macro creates the class header file.

The source file named CAAListOfSysPointVal.cpp is as follows:

#include "CAAListOfSysPointVal.h"

#include  "CATLISTV_Define.h"
CATLISTV_DEFINE(CAASysPoint)

The CATLISTV_DEFINE macro creates the class source file. The list of value class to the CAASysPoint class is now created. Its name is CATLISTV(CAASysPoint).

[Top]

Filling in a List of Values

  CATLISTV(CAASysPoint) lvCAASysPoint;

  CAASysPoint value0(0, 1);
  CAASysPoint value1(1, 2);
  CAASysPoint value2(2, 3);
  CAASysPoint value3(3, 4);
  CAASysPoint value4(4, 5);

  lvCAASysPoint.Append(value0);
  lvCAASysPoint.Append(value1);
  lvCAASysPoint.Append(value2);
  lvCAASysPoint.Append(value3);
  lvCAASysPoint.Append(value4);
  ...

The CATLISTV(CAASysPoint) class is first instantiated, and then instances of the CAASysPoint are created. Then the Append method appends values of the created points to the list.

[Top]

Locating Items

  ...
  int indexValue3 = lvCAASysPoint.Locate(value3);
  cout << "L1.Locate(value3) == " << indexValue3 << endl;

  float xValue3 = lvCAASysPoint[indexValue3].getX();
  float yValue3 = lvCAASysPoint[indexValue3].getY();
  ...

The Locate method returns the rank of a given value in the list. Note that this rank begins with 1. The located value 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(value3) == 4

[Top]

Removing Items

  ...
  lvCAASysPoint.RemoveValue(value1);
  lvCAASysPoint.RemoveValue(value3);
  ...

The RemoveValue method removes the value passed as parameter from the list. The list now includes three values to points value0, value2, and value4.

[Top]


In Short

This use case shows how to create a class for a list a values to a given class, and how to use it.

[Top]


References

[1] Lists of Values
[Top]

History

Version: 1 [Mar 2000] Document created
[Top]

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