Open Inventor Reference
SoNodekitCatalog.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  | Defines the SoNodekitCatalog class. This class is used to
48  | describe the subgraphs that make up different classes of
49  | nodekit.
50  |
51  | Author(s) : Paul Isaacs, Thad Beier
52  |
53  ______________ S I L I C O N G R A P H I C S I N C . ____________
54  _______________________________________________________________________
55 */
56 
57 #ifndef _SO_NODEKIT_CATALOG
58 #define _SO_NODEKIT_CATALOG
59 
60 #include <Inventor/misc/SoBasic.h>
61 #include <Inventor/SbString.h>
62 #include <Inventor/SoLists.h>
63 #include <Inventor/SoType.h>
64 
65 #define SO_CATALOG_NAME_NOT_FOUND -1
66 #define SO_CATALOG_THIS_PART_NUM 0
67 
77  private:
78  SbName name;
79  SoType type;
82  SoType defaultType;
85  bool nullByDefault;
88  bool leafPart;
90  SbName parentName;
91  SbName rightSiblingName;
92  bool listPart;
93  SoType listContainerType;
94  SoTypeList listItemTypes;
96  bool publicPart;
98  SoINTERNAL public:
100  SoNodekitCatalogEntry(const SbName &theName,
101  SoType theType, SoType theDefaultType,
102  bool theNullByDefault,
103  const SbName &theParentName, const SbName &theRightSiblingName,
104  bool theListPart, SoType theListContainerType,
105  const SoTypeList &theListItemTypes,
106  bool thePublicPart);
107 
111  SoType newDefaultType ) const;
112 
114  const SbName &getName() const { return name; };
115  SoType getType() const { return type; };
116  SoType getDefaultType() const { return defaultType; };
117  bool isNullByDefault() const { return nullByDefault; };
118  bool isLeaf() const { return leafPart; };
119  const SbName &getParentName() const { return parentName; };
120  const SbName &getRightSiblingName() const { return rightSiblingName; };
121  bool isList() const { return listPart; };
122  SoType getListContainerType() const {return listContainerType;};
123  const SoTypeList &getListItemTypes() const { return listItemTypes; };
124  bool isPublic() const { return publicPart; };
125 
127  void addListItemType( SoType typeToAdd );
128 
129  void setNullByDefault( bool newNullByDefault )
130  { nullByDefault = newNullByDefault; }
133  void setPublic( bool newPublic ) { publicPart = newPublic; }
134  void setLeaf( bool newLeafPart ) { leafPart = newLeafPart; }
135  void setRightSiblingName( const SbName &newN ) { rightSiblingName = newN; }
138  void setTypes( SoType newType, SoType newDefaultType )
139  { type = newType; defaultType = newDefaultType; }
140 
143  bool recursiveSearch( const SbName &nameToFind,
144  SoTypeList *typesChecked) const;
145 
146  void printCheck() const;
147 };
148 
149 
152 
184 
186 
187  public:
188 
190  static void initClass();
191 
193  int getNumEntries() const { return numEntries; };
194 
196  int getPartNumber( const SbName &theName ) const;
198  const SbName &getName( int thePartNumber ) const;
199  SoType getType( int thePartNumber ) const;
200  SoType getType( const SbName &theName ) const;
201  SoType getDefaultType( int thePartNumber ) const;
202  SoType getDefaultType( const SbName &theName ) const;
203  bool isNullByDefault( int thePartNumber ) const;
204  bool isNullByDefault( const SbName &theName ) const;
205  bool isLeaf( int thePartNumber ) const;
206  bool isLeaf( const SbName &theName ) const;
207  const SbName &getParentName( int thePartNumber ) const;
208  const SbName &getParentName( const SbName &theName ) const;
209  int getParentPartNumber( int thePartNumber ) const;
210  int getParentPartNumber(const SbName &theName ) const;
211  const SbName &getRightSiblingName( int thePartNumber ) const;
212  const SbName &getRightSiblingName(const SbName &theName ) const;
213  int getRightSiblingPartNumber( int thePartNumber ) const;
214  int getRightSiblingPartNumber(const SbName &theName ) const;
215  bool isList( int thePartNumber ) const;
216  bool isList( const SbName &theName ) const;
217  SoType getListContainerType( int thePartNumber ) const;
218  SoType getListContainerType( const SbName &theName ) const;
219  const SoTypeList &getListItemTypes( int thePartNumber ) const;
220  const SoTypeList &getListItemTypes( const SbName &theName ) const;
221  bool isPublic( int thePartNumber ) const;
222  bool isPublic( const SbName &theName ) const;
223 
224  SoEXTENDER public:
228 
231 
234 
237  SoNodekitCatalog *clone( SoType typeOfThis ) const;
238 
240  bool addEntry(const SbName &theName,
241  SoType theType, SoType theDefaultType,
242  bool theNullByDefault,
243  const SbName &theParentName,
244  const SbName &theRightSiblingName, bool theListPart,
245  SoType theListContainerType,
246  SoType theListItemType,
247  bool thePublicPart);
248 
250  void addListItemType(int thePartNumber, SoType typeToAdd);
251  void addListItemType(const SbName &theName, SoType typeToAdd);
252 
265  void narrowTypes( const SbName &theName, SoType newType,
266  SoType newDefaultType );
267 
268  void setNullByDefault( const SbName &theName, bool newNullByDefault );
269 
270  SoINTERNAL public:
274  bool recursiveSearch( int partNumber, const SbName &nameToFind,
275  SoTypeList *typesChecked) const;
276 
277  void printCheck() const;
278 
279  private:
280 
281  static const SbName *emptyName;
282  static const SoTypeList *emptyList;
283  static SoType *badType;
284 
285  int numEntries;
286  SoNodekitCatalogEntry **entries;
287  SbDict partNameDict;
288 
290  bool checkName( const SbName &theName );
291  bool checkNewName( const SbName &theName );
292  bool checkNewTypes( SoType theType,
293  SoType theDefaultType );
294  bool checkAndGetParent( const SbName &theName,
295  const SbName &theParentName,
296  SoNodekitCatalogEntry *& parentEntry );
297  bool checkAndGetSiblings( const SbName &theParentName,
298  const SbName &theRightSiblingName,
299  SoNodekitCatalogEntry *& leftEntry,
300  SoNodekitCatalogEntry *& rightEntry );
301  bool checkCanTypesBeList( SoType theType,
302  SoType theDefaultType,
303  SoType theListContainerType );
304 
305 };
306 
307 #endif /* _SO_NODEKIT_CATALOG */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
This is a dictionary mapping (size_t) integer keys to (void *) data pointers.
Definition: SbDict.h:101
Character string stored in a hash table.
Definition: SbString.h:264
an internal class that should be accessed only by an SoNodekitCatalog
const SoTypeList & getListItemTypes() const
void setRightSiblingName(const SbName &newN)
void setNullByDefault(bool newNullByDefault)
const SbName & getParentName() const
SoNodekitCatalogEntry * clone(SoType newType, SoType newDefaultType) const
SoNodekitCatalogEntry(const SbName &theName, SoType theType, SoType theDefaultType, bool theNullByDefault, const SbName &theParentName, const SbName &theRightSiblingName, bool theListPart, SoType theListContainerType, const SoTypeList &theListItemTypes, bool thePublicPart)
constructor
void setLeaf(bool newLeafPart)
const SbName & getName() const
inquiry functions:
SoType getListContainerType() const
SoNodekitCatalogEntry * clone() const
clone exactly, or make a clone with a given type...
void printCheck() const
prints the contents of this entry
bool isNullByDefault() const
void addListItemType(SoType typeToAdd)
For adding to the set of node types allowed beneath a list...
const SbName & getRightSiblingName() const
bool recursiveSearch(const SbName &nameToFind, SoTypeList *typesChecked) const
recursively search this entry for 'name to find' in the templates of this entry and its descendants
void setPublic(bool newPublic)
these should only by used by catalogs when an entry is given a new child or left sibling....
void setTypes(SoType newType, SoType newDefaultType)
This should only by used by catalogs when an entry is changing type and/or defaultType.
SoType getDefaultType() const
Nodekit catalog class.
SoType getListContainerType(int thePartNumber) const
SoType getListContainerType(const SbName &theName) const
SoType getType(int thePartNumber) const
bool isNullByDefault(const SbName &theName) const
bool addEntry(const SbName &theName, SoType theType, SoType theDefaultType, bool theNullByDefault, const SbName &theParentName, const SbName &theRightSiblingName, bool theListPart, SoType theListContainerType, SoType theListItemType, bool thePublicPart)
Adding entries.
SoType getDefaultType(const SbName &theName) const
void addListItemType(const SbName &theName, SoType typeToAdd)
bool isList(int thePartNumber) const
SoType getDefaultType(int thePartNumber) const
int getNumEntries() const
Returns number of entries in the catalog.
bool recursiveSearch(int partNumber, const SbName &nameToFind, SoTypeList *typesChecked) const
used by SoNodekitParts to search through catalogs.
int getParentPartNumber(const SbName &theName) const
static void initClass()
Initializes this object.
const SbName & getRightSiblingName(int thePartNumber) const
bool isPublic(const SbName &theName) const
int getRightSiblingPartNumber(const SbName &theName) const
bool isNullByDefault(int thePartNumber) const
void printCheck() const
prints the contents of this catalog
bool isPublic(int thePartNumber) const
const SoTypeList & getListItemTypes(int thePartNumber) const
const SoTypeList & getListItemTypes(const SbName &theName) const
void addListItemType(int thePartNumber, SoType typeToAdd)
For adding to the set of node types allowed beneath a list...
~SoNodekitCatalog()
Destructor.
bool isList(const SbName &theName) const
const SbName & getName(int thePartNumber) const
Given the part number of a part, returns its name in the catalog.
SoType getType(const SbName &theName) const
void narrowTypes(const SbName &theName, SoType newType, SoType newDefaultType)
For changing the type and defaultType of an entry.
void setNullByDefault(const SbName &theName, bool newNullByDefault)
int getParentPartNumber(int thePartNumber) const
SoNodekitCatalog * clone(SoType typeOfThis) const
Make a new identical copy, but you must give the node type for 'this' (where 'this' is the top level ...
SoNodekitCatalog()
Catalogs are only constructed, destructed, cloned or added to by subclasses of SoBaseKit.
const SbName & getRightSiblingName(const SbName &theName) const
int getPartNumber(const SbName &theName) const
Given the name of a part, returns its part number in the catalog.
const SbName & getParentName(const SbName &theName) const
int getRightSiblingPartNumber(int thePartNumber) const
bool isLeaf(int thePartNumber) const
bool isLeaf(const SbName &theName) const
const SbName & getParentName(int thePartNumber) const
Maintains a list of SoTypes.
Definition: SoLists.h:295
SoType has no virtual functions to keep it small...
Definition: SoType.h:103