Open Inventor Reference
|
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 | Defines the SoNodekitCatalog class. This class is used to 00048 | describe the subgraphs that make up different classes of 00049 | nodekit. 00050 | 00051 | Author(s) : Paul Isaacs, Thad Beier 00052 | 00053 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00054 _______________________________________________________________________ 00055 */ 00056 00057 #ifndef _SO_NODEKIT_CATALOG 00058 #define _SO_NODEKIT_CATALOG 00059 00060 #include <Inventor/misc/SoBasic.h> 00061 #include <Inventor/SbString.h> 00062 #include <Inventor/SoLists.h> 00063 #include <Inventor/SoType.h> 00064 00065 #define SO_CATALOG_NAME_NOT_FOUND -1 00066 #define SO_CATALOG_THIS_PART_NUM 0 00067 00076 SoINTERNAL class INVENTOR_API SoNodekitCatalogEntry { 00077 private: 00078 SbName name; 00079 SoType type; 00080 00081 00082 SoType defaultType; 00083 00084 00085 SbBool nullByDefault; 00086 00087 00088 SbBool leafPart; 00089 00090 SbName parentName; 00091 SbName rightSiblingName; 00092 SbBool listPart; 00093 SoType listContainerType; 00094 SoTypeList listItemTypes; 00095 00096 SbBool publicPart; 00097 00098 SoINTERNAL public: 00100 SoNodekitCatalogEntry(const SbName &theName, 00101 SoType theType, SoType theDefaultType, 00102 SbBool theNullByDefault, 00103 const SbName &theParentName, const SbName &theRightSiblingName, 00104 SbBool theListPart, SoType theListContainerType, 00105 const SoTypeList &theListItemTypes, 00106 SbBool thePublicPart); 00107 00109 SoNodekitCatalogEntry *clone() const; 00110 SoNodekitCatalogEntry *clone( SoType newType, 00111 SoType newDefaultType ) const; 00112 00114 const SbName &getName() const { return name; }; 00115 SoType getType() const { return type; }; 00116 SoType getDefaultType() const { return defaultType; }; 00117 SbBool isNullByDefault() const { return nullByDefault; }; 00118 SbBool isLeaf() const { return leafPart; }; 00119 const SbName &getParentName() const { return parentName; }; 00120 const SbName &getRightSiblingName() const { return rightSiblingName; }; 00121 SbBool isList() const { return listPart; }; 00122 SoType getListContainerType() const {return listContainerType;}; 00123 const SoTypeList &getListItemTypes() const { return listItemTypes; }; 00124 SbBool isPublic() const { return publicPart; }; 00125 00127 void addListItemType( SoType typeToAdd ); 00128 00129 void setNullByDefault( SbBool newNullByDefault ) 00130 { nullByDefault = newNullByDefault; } 00133 void setPublic( SbBool newPublic ) { publicPart = newPublic; } 00134 void setLeaf( SbBool newLeafPart ) { leafPart = newLeafPart; } 00135 void setRightSiblingName( const SbName &newN ) { rightSiblingName = newN; } 00138 void setTypes( SoType newType, SoType newDefaultType ) 00139 { type = newType; defaultType = newDefaultType; } 00140 00143 SbBool recursiveSearch( const SbName &nameToFind, 00144 SoTypeList *typesChecked) const; 00145 00146 void printCheck() const; 00147 }; 00148 00149 00152 00183 00184 00185 class INVENTOR_API SoNodekitCatalog { 00186 00187 public: 00188 00190 static void initClass(); 00191 00193 int getNumEntries() const { return numEntries; }; 00194 00196 int getPartNumber( const SbName &theName ) const; 00198 const SbName &getName( int thePartNumber ) const; 00199 SoType getType( int thePartNumber ) const; 00200 SoType getType( const SbName &theName ) const; 00201 SoType getDefaultType( int thePartNumber ) const; 00202 SoType getDefaultType( const SbName &theName ) const; 00203 SbBool isNullByDefault( int thePartNumber ) const; 00204 SbBool isNullByDefault( const SbName &theName ) const; 00205 SbBool isLeaf( int thePartNumber ) const; 00206 SbBool isLeaf( const SbName &theName ) const; 00207 const SbName &getParentName( int thePartNumber ) const; 00208 const SbName &getParentName( const SbName &theName ) const; 00209 int getParentPartNumber( int thePartNumber ) const; 00210 int getParentPartNumber(const SbName &theName ) const; 00211 const SbName &getRightSiblingName( int thePartNumber ) const; 00212 const SbName &getRightSiblingName(const SbName &theName ) const; 00213 int getRightSiblingPartNumber( int thePartNumber ) const; 00214 int getRightSiblingPartNumber(const SbName &theName ) const; 00215 SbBool isList( int thePartNumber ) const; 00216 SbBool isList( const SbName &theName ) const; 00217 SoType getListContainerType( int thePartNumber ) const; 00218 SoType getListContainerType( const SbName &theName ) const; 00219 const SoTypeList &getListItemTypes( int thePartNumber ) const; 00220 const SoTypeList &getListItemTypes( const SbName &theName ) const; 00221 SbBool isPublic( int thePartNumber ) const; 00222 SbBool isPublic( const SbName &theName ) const; 00223 00224 SoEXTENDER public: 00228 00230 SoNodekitCatalog(); 00231 00233 ~SoNodekitCatalog(); 00234 00237 SoNodekitCatalog *clone( SoType typeOfThis ) const; 00238 00240 SbBool addEntry(const SbName &theName, 00241 SoType theType, SoType theDefaultType, 00242 SbBool theNullByDefault, 00243 const SbName &theParentName, 00244 const SbName &theRightSiblingName, SbBool theListPart, 00245 SoType theListContainerType, 00246 SoType theListItemType, 00247 SbBool thePublicPart); 00248 00250 void addListItemType(int thePartNumber, SoType typeToAdd); 00251 void addListItemType(const SbName &theName, SoType typeToAdd); 00252 00265 void narrowTypes( const SbName &theName, SoType newType, 00266 SoType newDefaultType ); 00267 00268 void setNullByDefault( const SbName &theName, SbBool newNullByDefault ); 00269 00270 SoINTERNAL public: 00274 SbBool recursiveSearch( int partNumber, const SbName &nameToFind, 00275 SoTypeList *typesChecked) const; 00276 00277 void printCheck() const; 00278 00279 private: 00280 00281 static const SbName *emptyName; 00282 static const SoTypeList *emptyList; 00283 static SoType *badType; 00284 00285 int numEntries; 00286 SoNodekitCatalogEntry **entries; 00287 SbDict partNameDict; 00288 00290 SbBool checkName( const SbName &theName ); 00291 SbBool checkNewName( const SbName &theName ); 00292 SbBool checkNewTypes( SoType theType, 00293 SoType theDefaultType ); 00294 SbBool checkAndGetParent( const SbName &theName, 00295 const SbName &theParentName, 00296 SoNodekitCatalogEntry *& parentEntry ); 00297 SbBool checkAndGetSiblings( const SbName &theParentName, 00298 const SbName &theRightSiblingName, 00299 SoNodekitCatalogEntry *& leftEntry, 00300 SoNodekitCatalogEntry *& rightEntry ); 00301 SbBool checkCanTypesBeList( SoType theType, 00302 SoType theDefaultType, 00303 SoType theListContainerType ); 00304 00305 }; 00306 00307 #endif /* _SO_NODEKIT_CATALOG */