Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/database/include/Inventor/SoLists.h
Go to the documentation of this file.
00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 
00038 /*
00039  * Copyright (C) 1990,91   Silicon Graphics, Inc.
00040  *
00041  _______________________________________________________________________
00042  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00043  |
00044  |   $Revision: 1.1.1.1 $
00045  |
00046  |   Description:
00047  |      This file contains the definitions of subclasses of SbPList for
00048  |      some of the specific Inventor pointer types so that lists of
00049  |      pointers can be created easily.
00050  |
00051  |   Classes:
00052  |      subclasses of SbPList:
00053  |              SoBaseList
00054  |              SoNodeList
00055  |              SoPathList
00056  |              SoEngineList
00057  |              SoTypeList
00058  |              SoDetailList
00059  |              SoPickedPointList
00060  |              SoFieldList
00061  |              SoEngineOutputList
00062  |
00063  |   Author(s)          : Paul S. Strauss, Nick Thompson, David Mott,
00064  |                        Gavin Bell
00065  |
00066  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00067  _______________________________________________________________________
00068  */
00069 
00070 #ifndef  _SO_LISTS_
00071 #define  _SO_LISTS_
00072 
00073 #include <Inventor/system/SbSystem.h>
00074 #include <Inventor/SbPList.h>
00075 #include <Inventor/SoType.h>
00076 
00077 class SoBase;
00078 class SoDetail;
00079 class SoEngine;
00080 class SoEngineOutput;
00081 class SoField;
00082 class SoNode;
00083 class SoPath;
00084 class SoPickedPoint;
00085 
00098 
00101 
00115 
00116 
00117 class INVENTOR_API SoBaseList : public SbPList {
00118   public:
00120     SoBaseList();
00122     SoBaseList(int size);
00124     SoBaseList(const SoBaseList &l);
00126     ~SoBaseList()                       { truncate(0); }
00127 
00129     void                append(SoBase * ptr);
00130 
00132     void                insert(SoBase *ptr, int addBefore);
00133 
00135     void                remove(int which);
00136 
00138     void                truncate(int start);
00139 
00141     void                copy(const SoBaseList &l);
00143     SoBaseList &        operator =(const SoBaseList &l)
00144         { copy(l) ; return *this; }
00145 
00147     SoBase *            operator [](int i) const
00148         { return ( (SoBase *) ( (*(const SbPList *) this) [i] ) ); }
00149 
00151     void                set(int i, SoBase *ptr);
00152 
00155     void                addReferences(SbBool flag)      { addRefs = flag; }
00156 
00157   private:
00159     SbBool              addRefs;
00160 };
00161 
00164 
00175 
00176 
00177 class INVENTOR_API SoNodeList : public SoBaseList {
00178   public:
00179     SoNodeList()                        : SoBaseList()  {}
00180     SoNodeList(int size)                : SoBaseList(size) {}
00181     SoNodeList(const SoNodeList &l)     : SoBaseList(l) {}
00183     ~SoNodeList()                       { }
00184 
00186     void                append(SoNode * ptr)
00187         { ((SoBaseList *) this)->append((SoBase *) ptr); }
00188 
00190     SoNodeList &        operator =(const SoNodeList &l)
00191         { SoBaseList::copy(l) ; return *this; }
00192 
00193     SoNode *            operator [](int i) const
00194         { return ( (SoNode *) ( (*(const SoBaseList *) this) [i] ) ); }
00195 };
00196 
00199 
00210 
00211 
00212 class INVENTOR_API SoPathList : public SoBaseList {
00213   public:
00214     SoPathList()                        : SoBaseList()  {}
00215     SoPathList(int size)                : SoBaseList(size) {}
00216     SoPathList(const SoPathList &l)     : SoBaseList(l) {}
00218     ~SoPathList()                       { }
00219 
00221     void                append(SoPath * ptr)
00222         { ((SoBaseList *) this)->append((SoBase *) ptr); }
00223 
00225     SoPathList &        operator =(const SoPathList &l)
00226         { SoBaseList::copy(l) ; return *this; }
00227 
00228     SoPath *            operator [](int i) const
00229         { return ( (SoPath *) ( (*(const SoBaseList *) this) [i] ) ); }
00230 
00232     int                 findPath(const SoPath &path);
00233 
00236     void                sort();
00237 
00240     void                uniquify();
00241 
00242   private:
00244     static int          comparePaths(const void *p1Ptr, const void *p2Ptr);
00245 };
00246 
00249 
00260 
00261 
00262 class INVENTOR_API SoEngineList : public SoBaseList {
00263   public:
00264     SoEngineList()                      : SoBaseList()  {}
00265     SoEngineList(int size)              : SoBaseList(size) {}
00266     SoEngineList(const SoEngineList &l) : SoBaseList(l) {}
00268     ~SoEngineList()                     { }
00269 
00271     void                append(SoEngine * ptr)
00272         { ((SoBaseList *) this)->append((SoBase *) ptr); }
00273 
00275     SoEngineList &      operator =(const SoEngineList &l)
00276         { SoBaseList::copy(l) ; return *this; }
00277 
00278     SoEngine *          operator [](int i) const
00279         { return ( (SoEngine *) ( (*(const SoBaseList *) this) [i] ) ); }
00280 };
00281 
00284 
00293 
00294 
00295 class INVENTOR_API SoTypeList : public SbPList {
00296   public:
00297     SoTypeList()                        : SbPList()     {}
00298     SoTypeList(int size)                : SbPList(size) {}
00299     SoTypeList(const SoTypeList &l)     : SbPList(l)    {}
00301     ~SoTypeList()                       { truncate(0); }
00302 
00304     void                append(SoType typeId);
00305 
00307     int                 find(SoType typeId) const;
00308 
00310     void                insert(SoType typeId, int addBefore);
00311 
00313     SoType              operator [](int i) const;
00314 
00316     void                set(int i, SoType typeId);
00317 };
00318 
00321 
00331 
00332 
00333 class INVENTOR_API SoDetailList : public SbPList {
00334   public:
00335     SoDetailList()                      : SbPList()     {}
00336     SoDetailList(int size)              : SbPList(size) {}
00338     SoDetailList(const SoDetailList &l);
00340     ~SoDetailList()                     { truncate(0); }
00341 
00343     void                append(SoDetail *detail)
00344         { SbPList::append((void *) detail); }
00345 
00347     void                insert(SoDetail *detail, int addBefore)
00348         { SbPList::insert((void *) detail, addBefore); }
00349 
00352     void                truncate(int start);
00353 
00355     void                copy(const SoDetailList &l);
00357     SoDetailList &      operator =(const SoDetailList &l)
00358         { copy(l) ; return *this; }
00359 
00361     SoDetail *          operator [](int i) const
00362         { return ( (SoDetail *) ( (* (const SbPList *) this) [i] ) ); }
00363 
00365     void                set(int i, SoDetail *detail);
00366 };
00367 
00370 
00381 
00382 
00383 class INVENTOR_API SoPickedPointList : public SbPList {
00384   public:
00385     SoPickedPointList()                 : SbPList()     {}
00386     SoPickedPointList(int size)         : SbPList(size) {}
00388     SoPickedPointList(const SoPickedPointList &l);
00390     ~SoPickedPointList()                                { truncate(0); }
00391 
00393     void                append(SoPickedPoint *pickedPoint)
00394         { SbPList::append((void *) pickedPoint); }
00395 
00397     void                insert(SoPickedPoint *pickedPoint, int addBefore)
00398         { SbPList::insert((void *) pickedPoint, addBefore); }
00399 
00402     void                truncate(int start);
00403 
00405     SoPickedPoint *     operator [](int i) const
00406         { return ( (SoPickedPoint *) ( (* (const SbPList *) this) [i] ) ); }
00407 
00409     void                set(int i, SoPickedPoint *pickedPoint);
00410 };
00411 
00414 
00424 
00425 
00426 class INVENTOR_API SoFieldList : public SbPList {
00427   public:
00428     SoFieldList()                       : SbPList()     {}
00429     SoFieldList(int size)               : SbPList(size) {}
00430     SoFieldList(const SoFieldList &l)   : SbPList(l)    {}
00432     ~SoFieldList()                      { truncate(0); }
00433 
00435     void                append(SoField *field)
00436         { SbPList::append((void *) field); }
00437 
00439     void                insert(SoField *field, int addBefore)
00440         { SbPList::insert((void *) field, addBefore); }
00441 
00443     SoField *           operator [](int i) const
00444         { return ( (SoField *) ( (* (const SbPList *) this) [i] ) ); }
00445 
00447     void                set(int i, SoField *Field)
00448         { (* (const SbPList *) this) [i] = (void *) Field; }
00449 
00451   SoINTERNAL public:
00452     SoField *           get(int i) const
00453         { return (SoField *)SbPList::get(i); }
00454 };
00455 
00458 
00469 
00470 
00471 class INVENTOR_API SoEngineOutputList : public SbPList {
00472   public:
00473     SoEngineOutputList()                        : SbPList()     {}
00474     SoEngineOutputList(int size)                : SbPList(size) {}
00475     SoEngineOutputList(const SoEngineOutputList &l)     : SbPList(l)    {}
00477     ~SoEngineOutputList()                       { truncate(0); }
00478 
00480     void                append(SoEngineOutput *engineOutput)
00481         { SbPList::append((void *) engineOutput); }
00482 
00485     void                insert(SoEngineOutput *engineOutput, int addBefore)
00486         { SbPList::insert((void *) engineOutput, addBefore); }
00487 
00489     SoEngineOutput *            operator [](int i) const
00490         { return ( (SoEngineOutput *) ( (* (const SbPList *) this) [i] ) ); }
00491 
00493     void                set(int i, SoEngineOutput *engineOutput)
00494         { (* (const SbPList *) this) [i] = (void *) engineOutput; }
00495 };
00496 
00498 
00499 #endif /* _SO_LISTS_ */