3D PLM Enterprise Architecture

Middleware Abstraction

Lists of Pointers

Managing pointers to instances of the same class
Quick Reference

Abstract

You often need to manage several objects at the same time rather than a single one, either to handle them as a whole or to pass them as an argument of a method. The list of pointers enables you to gather pointers to instances of the same class in a list and provides many methods to handle them.


About Lists of Pointers?

The following applies to list of pointers:

Do not use CATLISTP(T) with T as a non-class (int or double for example), it is doesn't make sense.

[Top]

Programmer's Guide

To create a class for a list a pointers to MyClass, with the two methods Append and RemoveValue, create the following header file.

class MyClass;                     // Declare the class

#include "CATLISTP_Clean.h"        // Clean previous method requests

#define CATLISTP_Append            // Request the methods to create
#define CATLISTP_RemoveValue

#include "CATLISTP_Declare.h"      // Include macros

CATLISTP_DECLARE(MyClass);         // Declare the collection class

typedef CATLISTP(MyClass) MyClassCollection; // Define a handy name

The source file is as follows.

#include "MyClass.h"
#include "MyClassCollection.h"

#include "CATLISTP_Define.h"

CATLISTP_DEFINE(MyClass);

[Top]

Programmer's Reference

All the methods that you can set yo a list of pointers class are declared in CATLISTP_AllFunc.h.

#define	CATLISTP_CtorFromArrayPtrs
#define	CATLISTP_Append
#define	CATLISTP_AppendList
#define	CATLISTP_InsertAt
#define	CATLISTP_ReSize
#define	CATLISTP_Locate
#define	CATLISTP_RemoveValue
#define	CATLISTP_RemoveList
#define	CATLISTP_RemovePosition
#define	CATLISTP_RemoveAll
#define	CATLISTP_RemoveNulls
#define	CATLISTP_RemoveDuplicates
#define	CATLISTP_Compare
#define	CATLISTP_Swap
#define	CATLISTP_QuickSort
#define	CATLISTP_FillArrayPtrs
#define	CATLISTP_NbOccur
#define	CATLISTP_Intersection

Including first CATLISTP_Clean.h ensures that no previously declared method remains.

[Top]

Constructing a List of Pointers

You can construct a list of pointers using the following constructors.

Note that the destructor doesn't delete the pointed objects. Refer to the ApplyDelete method

[Top]

Copying a List of Pointers

You can copy a list a pointers in an existing one as follows.

[Top]

Adding Items to a List of Pointers

You can add items to a list of pointers as follows.

[Top]

Removing Items from a List of Pointers

You can remove items to a list of pointers as follows.

[Top]

Retrieving and Setting the List Size

You can retrieve and set the size of a list of pointers as follows.

[Top]

Retrieving and Locating Items

You can retrieve items from and locate items in a list of pointers as follows.

[Top]

Replacing, Swapping, and Sorting Items

You can replace, swap, and sort items in a list of pointers as follows.

[Top]

Applying Operations to Pointed Objects

You can apply the following operations to items of a list of pointers as follows.

[Top]

Comparing Items

You can compare items of two lists of pointers as follows.

[Top]

Doing More

You can do the following:


History

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

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