Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoNodekitCatalog.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul Isaacs (MMM yyyy)
25** Modified by : Thad Beier (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50
51#ifndef _SO_NODEKIT_CATALOG
52#define _SO_NODEKIT_CATALOG
53
55#include <Inventor/SbString.h>
56#include <Inventor/SoLists.h>
57#include <Inventor/SoType.h>
58
59#define SO_CATALOG_NAME_NOT_FOUND -1
60#define SO_CATALOG_THIS_PART_NUM 0
61
62#ifndef HIDDEN_FROM_DOC
64//
65// Class: SoNodekitCatalogEntry
66//
67// an internal class that should be accessed only by an SoNodekitCatalog
68//
69//
71{
72 private:
73 SbName name; // Reference name of this entry
74 SoType type; // Type of node allowable for setting
75 // this entry. 'type' may be an
76 // abstract node type
77 SoType defaultType; // Type of node to create if the nodekit
78 // is asked to build this part itself.
79 // May not be an abstract node type.
80 SbBool nullByDefault; // If FALSE, then this part is
81 // created within the constructor.
82 // Otherwise, it isn't.
83 SbBool leafPart; // Is this entry a leaf node in the
84 // nodekit's structure?
85 SbName parentName; // Reference name of this entry's parent
86 SbName rightSiblingName; // Name of right sibling of the entry
87 SbBool listPart; // Is this entry a list of nodes?
88 SoType listContainerType; // If so, what kind of container?
89 SoTypeList listItemTypes; // If so, what types of nodes may
90 // it contain?
91 SbBool publicPart; // Can a user be given a pointer to
92 // this part?
93 private:
94 // constructor
95 SoNodekitCatalogEntry(const SbName &theName,
96 SoType theType, SoType theDefaultType,
97 SbBool theNullByDefault,
98 const SbName &theParentName, const SbName &theRightSiblingName,
99 SbBool theListPart, SoType theListContainerType,
100 const SoTypeList &theListItemTypes,
101 SbBool thePublicPart);
102
103 // clone exactly, or make a clone with a given type...
104 SoNodekitCatalogEntry *clone() const;
105 SoNodekitCatalogEntry *clone( SoType newType,
106 SoType newDefaultType ) const;
107
108 // inquiry functions:
109 const SbName &getName() const { return name; };
110 SoType getType() const { return type; };
111 SoType getDefaultType() const { return defaultType; };
112 SbBool isNullByDefault() const { return nullByDefault; };
113 SbBool isLeaf() const { return leafPart; };
114 const SbName &getParentName() const { return parentName; };
115 const SbName &getRightSiblingName() const { return rightSiblingName; };
116 SbBool isList() const { return listPart; };
117 SoType getListContainerType() const {return listContainerType;};
118 const SoTypeList &getListItemTypes() const { return listItemTypes; };
119 SbBool isPublic() const { return publicPart; };
120
121 // For adding to the set of node types allowed beneath a list...
122 void addListItemType( SoType typeToAdd );
123
124 void setNullByDefault( SbBool newNullByDefault )
125 { nullByDefault = newNullByDefault; }
126 // these should only by used by catalogs when an entry
127 // is given a new child or left sibling...
128 void setPublic( SbBool newPublic ) { publicPart = newPublic; }
129 void setLeaf( SbBool newLeafPart ) { leafPart = newLeafPart; }
130 void setRightSiblingName( const SbName &newN ) { rightSiblingName = newN; }
131 // This should only by used by catalogs when an entry is changing
132 // type and/or defaultType
133 void setTypes( SoType newType, SoType newDefaultType )
134 { type = newType; defaultType = newDefaultType; }
135
136 // recursively search this entry for 'name to find' in the
137 // templates of this entry and its descendants
138 SbBool recursiveSearch( const SbName &nameToFind,
139 SoTypeList *typesChecked) const;
140
141 void printCheck() const; // prints the contents of this entry
142};
143#endif // HIDDEN_FROM_DOC
144
188
189 private:
190
194 static void initClass();
195 static void exitClass();
196
197 public:
198
202 int getNumEntries() const { return numEntries; };
203
204 // inquiry routines, to find out about entries in the catalog,
205 // Questions may be asked based on name or partNumber.
206#ifdef DEBUG_NODEKITS
210 long getPartNumber( const SbName &theName ) const;
211#else
215 int getPartNumber( const SbName &theName ) const;
216#endif
220 const SbName &getName( int thePartNumber ) const;
224 SoType getType( int thePartNumber ) const;
228 SoType getType( const SbName &theName ) const;
232 SoType getDefaultType( int thePartNumber ) const;
236 SoType getDefaultType( const SbName &theName ) const;
240 SbBool isNullByDefault( int thePartNumber ) const;
244 SbBool isNullByDefault( const SbName &theName ) const;
248 SbBool isLeaf( int thePartNumber ) const;
252 SbBool isLeaf( const SbName &theName ) const;
256 const SbName &getParentName( int thePartNumber ) const;
260 const SbName &getParentName( const SbName &theName ) const;
264 int getParentPartNumber( int thePartNumber ) const;
268 int getParentPartNumber(const SbName &theName ) const;
272 const SbName &getRightSiblingName( int thePartNumber ) const;
276 const SbName &getRightSiblingName(const SbName &theName ) const;
280 int getRightSiblingPartNumber( int thePartNumber ) const;
284 int getRightSiblingPartNumber(const SbName &theName ) const;
288 SbBool isList( int thePartNumber ) const;
292 SbBool isList( const SbName &theName ) const;
296 SoType getListContainerType( int thePartNumber ) const;
300 SoType getListContainerType( const SbName &theName ) const;
305 const SoTypeList &getListItemTypes( int thePartNumber ) const;
310 const SoTypeList &getListItemTypes( const SbName &theName ) const;
314 SbBool isPublic( int thePartNumber ) const;
318 SbBool isPublic( const SbName &theName ) const;
319
320 private:
321 // Catalogs are only constructed, destructed, cloned or added to
322 // by subclasses of SoBaseKit.
323 // This should be accomplished using the macros provided in SoSubKit.h
324
325 // Constructor
327
328 // Destructor
330
331 // Make a new identical copy, but you must give the node type for 'this'
332 // (where 'this' is the top level node in the template )
333 SoNodekitCatalog *clone( SoType typeOfThis ) const;
334
335 // Adding entries
336 SbBool addEntry(const SbName &theName,
337 SoType theType, SoType theDefaultType,
338 SbBool theNullByDefault,
339 const SbName &theParentName,
340 const SbName &theRightSiblingName, SbBool theListPart,
341 SoType theListContainerType,
342 SoType theListItemType,
343 SbBool thePublicPart);
344
345 // For adding to the set of node types allowed beneath a list...
346 void addListItemType(int thePartNumber, SoType typeToAdd);
347 void addListItemType(const SbName &theName, SoType typeToAdd);
348
349 // For changing the type and defaultType of an entry.
350 // The new types must be subclasses of the types already existing in the
351 // entry.
352 // For example, in SoShapeKit, the part "shape" has type SoShape and
353 // default type SoSphere. Any shape node is acceptable, but be default a
354 // sphere will be built.
355 // Well, when creating the SoVertexShapeKit class, a call of:
356 // narrowTypes( "shape", SoVertexShape::getClassTypeId(),
357 // SoFaceSet::getClassTypeId())
358 // might be used. This would reflect the fact that:
359 // Only vertext shapes may be put in the "shape" part, not just any shape.
360 // And also, by default, a faceSet will be built, not a sphere.
361 void narrowTypes( const SbName &theName, SoType newType,
362 SoType newDefaultType );
363
364 void setNullByDefault( const SbName &theName, SbBool newNullByDefault );
365
366 private:
367 // used by SoNodekitParts to search through catalogs.
368 // recursively search a given part for 'name to find' in the
369 // templates of that entry and its descendants
370 SbBool recursiveSearch( int partNumber, const SbName &nameToFind,
371 SoTypeList *typesChecked) const;
372
373 void printCheck() const; // prints the contents of this catalog
374
375 private:
376 static const SbName *emptyName;
377 static const SoTypeList *emptyList;
378 static SoType *badType;
379
380 int numEntries; // how many entries?
381 SoNodekitCatalogEntry **entries; // the array of entries
382 SbDict partNameDict; // For fast lookup of part numbers
383
384 // Used for testing various aspects of new entries into a catalog
385 SbBool checkName( const SbName &theName );
386 SbBool checkNewName( const SbName &theName );
387 SbBool checkNewTypes( SoType theType,
388 SoType theDefaultType );
389 SbBool checkAndGetParent( const SbName &theName,
390 const SbName &theParentName,
391 SoNodekitCatalogEntry *& parentEntry );
392 SbBool checkAndGetSiblings( const SbName &theParentName,
393 const SbName &theRightSiblingName,
394 SoNodekitCatalogEntry *& leftEntry,
395 SoNodekitCatalogEntry *& rightEntry );
396 SbBool checkCanTypesBeList( SoType theType,
397 SoType theDefaultType,
398 SoType theListContainerType );
399
400};
401
402#endif /* _SO_NODEKIT_CATALOG */
403
virtual SoGLGraphicDevice::DeviceType getType()=0
Returns the type of device.
Character string stored in a hash table.
Definition SbName.h:162
Nodekit catalog class.
SoType getListContainerType(int thePartNumber) const
Returns the list container type of the specified part.
SoType getListContainerType(const SbName &theName) const
Returns the list container type of the specified part.
SoType getType(int thePartNumber) const
Returns the type of the specified part.
const SoTypeList & getListItemTypes(const SbName &theName) const
Returns a list of the types of nodes that the specified part can contain.
SoType getDefaultType(const SbName &theName) const
Returns the default type of the specified part.
SoType getDefaultType(int thePartNumber) const
Returns the default type of the specified part.
int getNumEntries() const
Returns the number of entries in the catalog.
int getParentPartNumber(const SbName &theName) const
Returns the part number of the parent of the specified part.
SbBool isLeaf(int thePartNumber) const
Returns TRUE if the specified part is a leaf node.
const SbName & getParentName(const SbName &theName) const
Returns the parent of the specified part.
SbBool isList(const SbName &theName) const
Returns TRUE if the specified part is a parts list.
const SbName & getRightSiblingName(int thePartNumber) const
Returns the name of the right sibling of the specified part.
const SbName & getRightSiblingName(const SbName &theName) const
Returns the name of the right sibling of the specified part.
int getRightSiblingPartNumber(const SbName &theName) const
Returns the part number of the right sibling of the specified part.
SbBool isLeaf(const SbName &theName) const
Returns TRUE if the specified part is a leaf node.
SbBool isPublic(const SbName &theName) const
Returns TRUE if the specified part is public.
SbBool isList(int thePartNumber) const
Returns TRUE if the specified part is a parts list.
const SbName & getParentName(int thePartNumber) const
Returns the parent of the specified part.
const SoTypeList & getListItemTypes(int thePartNumber) const
Returns a list of the types of nodes that the specified part can contain.
SoType getType(const SbName &theName) const
Returns the type of the specified part.
SbBool isNullByDefault(int thePartNumber) const
Returns TRUE if the specified part is null by default.
int getParentPartNumber(int thePartNumber) const
Returns the part number of the parent of the specified part.
int getPartNumber(const SbName &theName) const
Given the name of a part, returns its part number in the catalog.
SbBool isPublic(int thePartNumber) const
Returns TRUE if the specified part is public.
SbBool isNullByDefault(const SbName &theName) const
Returns TRUE if the specified part is null by default.
const SbName & getName(int thePartNumber) const
Given the part number of a part, returns its name in the catalog.
int getRightSiblingPartNumber(int thePartNumber) const
Returns the part number of the right sibling of the specified part.
Stores runtime type information.
Definition SoType.h:98
Maintains a list of SoTypes.
Definition SoTypeList.h:72
int SbBool
Boolean type.
Definition SbBase.h:87