Open Inventor Reference
SoLists.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990,91 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 | $Revision: 1.1.1.1 $
45 |
46 | Description:
47 | This file contains the definitions of subclasses of SbPList for
48 | some of the specific Inventor pointer types so that lists of
49 | pointers can be created easily.
50 |
51 | Classes:
52 | subclasses of SbPList:
53 | SoBaseList
54 | SoNodeList
55 | SoPathList
56 | SoEngineList
57 | SoTypeList
58 | SoDetailList
59 | SoPickedPointList
60 | SoFieldList
61 | SoEngineOutputList
62 |
63 | Author(s) : Paul S. Strauss, Nick Thompson, David Mott,
64 | Gavin Bell
65 |
66 ______________ S I L I C O N G R A P H I C S I N C . ____________
67 _______________________________________________________________________
68 */
69
70#ifndef _SO_LISTS_
71#define _SO_LISTS_
72
74#include <Inventor/SbPList.h>
75#include <Inventor/SoType.h>
76
77class SoBase;
78class SoDetail;
79class SoEngine;
80class SoEngineOutput;
81class SoField;
82class SoNode;
83class SoPath;
84class SoPickedPoint;
85
98
101
116
118 public:
122 SoBaseList(int size);
127
129 void append(SoBase * ptr);
130
132 void insert(SoBase *ptr, int addBefore);
133
135 void remove(int which);
136
138 void truncate(int start);
139
141 void copy(const SoBaseList &l);
144 { copy(l) ; return *this; }
145
147 SoBase * operator [](int i) const
148 { return ( (SoBase *) ( (*(const SbPList *) this) [i] ) ); }
149
151 void set(int i, SoBase *ptr);
152
155 void addReferences(bool flag) { addRefs = flag; }
156
157 private:
159 bool addRefs;
160};
161
164
176
178 public:
180 SoNodeList(int size) : SoBaseList(size) {}
184
186 void append(SoNode * ptr)
187 { ((SoBaseList *) this)->append((SoBase *) ptr); }
188
191 { SoBaseList::copy(l) ; return *this; }
192
193 SoNode * operator [](int i) const
194 { return ( (SoNode *) ( (*(const SoBaseList *) this) [i] ) ); }
195};
196
199
211
213 public:
215 SoPathList(int size) : SoBaseList(size) {}
219
221 void append(SoPath * ptr)
222 { ((SoBaseList *) this)->append((SoBase *) ptr); }
223
226 { SoBaseList::copy(l) ; return *this; }
227
228 SoPath * operator [](int i) const
229 { return ( (SoPath *) ( (*(const SoBaseList *) this) [i] ) ); }
230
232 int findPath(const SoPath &path);
233
236 void sort();
237
240 void uniquify();
241
242 private:
244 static int comparePaths(const void *p1Ptr, const void *p2Ptr);
245};
246
249
261
263 public:
265 SoEngineList(int size) : SoBaseList(size) {}
269
271 void append(SoEngine * ptr)
272 { ((SoBaseList *) this)->append((SoBase *) ptr); }
273
276 { SoBaseList::copy(l) ; return *this; }
277
278 SoEngine * operator [](int i) const
279 { return ( (SoEngine *) ( (*(const SoBaseList *) this) [i] ) ); }
280};
281
284
294
296 public:
298 SoTypeList(int size) : SbPList(size) {}
299 SoTypeList(const SoTypeList &l) : SbPList(l) {}
302
304 void append(SoType typeId);
305
307 int find(SoType typeId) const;
308
310 void insert(SoType typeId, int addBefore);
311
313 SoType operator [](int i) const;
314
316 void set(int i, SoType typeId);
317};
318
321
332
334 public:
336 SoDetailList(int size) : SbPList(size) {}
341
343 void append(SoDetail *detail)
344 { SbPList::append((void *) detail); }
345
347 void insert(SoDetail *detail, int addBefore)
348 { SbPList::insert((void *) detail, addBefore); }
349
352 void truncate(int start);
353
355 void copy(const SoDetailList &l);
358 { copy(l) ; return *this; }
359
361 SoDetail * operator [](int i) const
362 { return ( (SoDetail *) ( (* (const SbPList *) this) [i] ) ); }
363
365 void set(int i, SoDetail *detail);
366};
367
370
382
384 public:
386 SoPickedPointList(int size) : SbPList(size) {}
391
393 void append(SoPickedPoint *pickedPoint)
394 { SbPList::append((void *) pickedPoint); }
395
397 void insert(SoPickedPoint *pickedPoint, int addBefore)
398 { SbPList::insert((void *) pickedPoint, addBefore); }
399
402 void truncate(int start);
403
406 { return ( (SoPickedPoint *) ( (* (const SbPList *) this) [i] ) ); }
407
409 void set(int i, SoPickedPoint *pickedPoint);
410};
411
414
425
427 public:
429 SoFieldList(int size) : SbPList(size) {}
433
435 void append(SoField *field)
436 { SbPList::append((void *) field); }
437
439 void insert(SoField *field, int addBefore)
440 { SbPList::insert((void *) field, addBefore); }
441
443 SoField * operator [](int i) const
444 { return ( (SoField *) ( (* (const SbPList *) this) [i] ) ); }
445
447 void set(int i, SoField *Field)
448 { (* (const SbPList *) this) [i] = (void *) Field; }
449
451 SoINTERNAL public:
452 SoField * get(int i) const
453 { return (SoField *)SbPList::get(i); }
454};
455
458
470
472 public:
474 SoEngineOutputList(int size) : SbPList(size) {}
478
480 void append(SoEngineOutput *engineOutput)
481 { SbPList::append((void *) engineOutput); }
482
485 void insert(SoEngineOutput *engineOutput, int addBefore)
486 { SbPList::insert((void *) engineOutput, addBefore); }
487
490 { return ( (SoEngineOutput *) ( (* (const SbPList *) this) [i] ) ); }
491
493 void set(int i, SoEngineOutput *engineOutput)
494 { (* (const SbPList *) this) [i] = (void *) engineOutput; }
495};
496
498
499#endif /* _SO_LISTS_ */
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
List of generic (void *) pointers.
Definition SbPList.h:78
void append(void *ptr)
Adds given pointer to end of list.
Definition SbPList.h:96
void truncate(int start)
Removes all pointers after one with given index, inclusive.
Definition SbPList.h:113
SbPList & operator=(const SbPList &pl)
Assignment operator; copies list into this list.
Definition SbPList.h:120
void *& operator[](int i) const
Returns pointer with given index.
Definition SbPList.h:123
void copy(const SbPList &pl)
Copy a list.
void * get(int i) const
Internal versions of [] that do not check for bounds:
Definition SbPList.h:135
void insert(void *ptr, int addBefore)
Inserts given pointer in list before pointer with given index.
Subclasses of the SbPList class which hold lists of pointers of a specific type.
Definition SoLists.h:117
void copy(const SoBaseList &l)
Copies a list, keeping all reference counts correct.
SoBaseList(int size)
Constructor that pre-allocates storage for size pointers.
void insert(SoBase *ptr, int addBefore)
Inserts given pointer in list before pointer with given index.
void set(int i, SoBase *ptr)
Sets an element of a list.
SoBaseList(const SoBaseList &l)
Constructor that copies the contents of another list.
SoBaseList()
Constructor.
void addReferences(bool flag)
Indicates whether to call ref() and unref() for bases in the list when adding/removing them.
Definition SoLists.h:155
void truncate(int start)
Removes all pointers after one with given index, inclusive.
void append(SoBase *ptr)
Adds a pointer to the end of the list.
~SoBaseList()
Destructor.
Definition SoLists.h:126
void remove(int which)
Removes pointer with given index.
Base class for all nodes, paths, and engines.
Definition SoBase.h:90
Maintains a list of instances of details.
Definition SoLists.h:333
void copy(const SoDetailList &l)
Copies a list, making a copy of each detail instance in the list.
void truncate(int start)
Removes all details after one with given index, inclusive.
SoDetailList(const SoDetailList &l)
Constructor that copies the contents of another list.
~SoDetailList()
Destructor.
Definition SoLists.h:340
SoDetailList(int size)
Definition SoLists.h:336
void insert(SoDetail *detail, int addBefore)
Inserts given detail in list before detail with given index.
Definition SoLists.h:347
void set(int i, SoDetail *detail)
Sets an element of a list, deleting the old entry first.
void append(SoDetail *detail)
Adds a detail to the end of the list.
Definition SoLists.h:343
Base class for describing detail information about a shape node.
Definition SoDetail.h:78
Maintains a list of pointers to engines.
Definition SoLists.h:262
void append(SoEngine *ptr)
Adds an engine to the end of the list.
Definition SoLists.h:271
SoEngineList(int size)
Definition SoLists.h:265
SoEngineList(const SoEngineList &l)
Definition SoLists.h:266
~SoEngineList()
Destructor.
Definition SoLists.h:268
Maintains a list of pointers to engine outputs.
Definition SoLists.h:471
SoEngineOutputList(const SoEngineOutputList &l)
Definition SoLists.h:475
SoEngineOutputList(int size)
Definition SoLists.h:474
~SoEngineOutputList()
Destructor.
Definition SoLists.h:477
void append(SoEngineOutput *engineOutput)
Adds an engine output to the end of the list.
Definition SoLists.h:480
void set(int i, SoEngineOutput *engineOutput)
Sets an element of a list.
Definition SoLists.h:493
void insert(SoEngineOutput *engineOutput, int addBefore)
Inserts the given engine output in the list before the element of the given index.
Definition SoLists.h:485
Class for all engine outputs.
Definition SoEngine.h:228
Base class for all engines.
Definition SoEngine.h:102
Maintains a list of pointers to fields.
Definition SoLists.h:426
void insert(SoField *field, int addBefore)
Inserts given pointer in list before pointer with given index.
Definition SoLists.h:439
SoFieldList(int size)
Definition SoLists.h:429
SoField * get(int i) const
Internal versions of [] that do not check for bounds:
Definition SoLists.h:452
void set(int i, SoField *Field)
Sets an element of a list.
Definition SoLists.h:447
void append(SoField *field)
Adds a pointer to the end of the list.
Definition SoLists.h:435
SoFieldList(const SoFieldList &l)
Definition SoLists.h:430
~SoFieldList()
Destructor.
Definition SoLists.h:432
Base class for all fields.
Definition SoField.h:185
Maintains a list of pointers to nodes.
Definition SoLists.h:177
void append(SoNode *ptr)
Adds a pointer to the end of the list.
Definition SoLists.h:186
SoNodeList(const SoNodeList &l)
Definition SoLists.h:181
~SoNodeList()
Destructor.
Definition SoLists.h:183
SoNodeList(int size)
Definition SoLists.h:180
Abstract base class for all database nodes.
Definition SoNode.h:103
Maintains a list of pointers to paths.
Definition SoLists.h:212
void sort()
Sorts list in place based on (1) increasing address of head node, then (2) increasing indices of chil...
void uniquify()
Given a sorted list, removes any path that (1) is a duplicate, or (2) goes through a node that is the...
int findPath(const SoPath &path)
Returns the index of the matching path in the list, or -1 if not found.
~SoPathList()
Destructor.
Definition SoLists.h:218
SoPathList(const SoPathList &l)
Definition SoLists.h:216
void append(SoPath *ptr)
Adds a path to the end of the list.
Definition SoLists.h:221
SoPathList(int size)
Definition SoLists.h:215
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
Maintains a list of pointers to SoPickedPoint instances.
Definition SoLists.h:383
SoPickedPointList(const SoPickedPointList &l)
Constructor that copies the contents of another list.
void insert(SoPickedPoint *pickedPoint, int addBefore)
Inserts given pointer in list before pointer with given index.
Definition SoLists.h:397
~SoPickedPointList()
Destructor.
Definition SoLists.h:390
void append(SoPickedPoint *pickedPoint)
Adds a pointer to the end of the list.
Definition SoLists.h:393
SoPickedPointList(int size)
Definition SoLists.h:386
void set(int i, SoPickedPoint *pickedPoint)
Sets an element of a list.
void truncate(int start)
Removes all pointers after one with given index, inclusive, deleting all instances removed from the l...
Represents point on surface of picked object.
Maintains a list of SoTypes.
Definition SoLists.h:295
void append(SoType typeId)
Adds a type to the end of the list.
int find(SoType typeId) const
Returns index of given type in list, or -1 if not found.
~SoTypeList()
Destructor.
Definition SoLists.h:301
void insert(SoType typeId, int addBefore)
Inserts given type in list before type with given index.
SoTypeList(const SoTypeList &l)
Definition SoLists.h:299
void set(int i, SoType typeId)
Sets an element of a list.
SoTypeList(int size)
Definition SoLists.h:298
SoType has no virtual functions to keep it small...
Definition SoType.h:103