00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Paul S. Strauss (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2017 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_CHILD_LIST_ 00051 #define _SO_CHILD_LIST_ 00052 00053 #include <Inventor/SoLists.h> 00054 #include <Inventor/threads/SbThreadMutex.h> 00055 #include <Inventor/sensors/SoDataSensor.h> 00056 00057 00059 // 00060 // Class: SoChildList 00061 // 00062 // This class maintains a list of child nodes for any node. It allows 00063 // children to be added, removed, replaced, and accessed. The SoGroup 00064 // class has an instance of this class and provides public methods 00065 // for dealing with children. Other classes can also have an instance 00066 // of this class and may choose to publicize whatever methods they 00067 // wish for dealing with them. The SoNode::getChildren() method 00068 // returns the child list for any node class. 00069 // 00070 // SoChildList automatically maintains the auditor list for parent 00071 // nodes. That is, when a child is added to the list, the parent node 00072 // is automatically added as a parent auditor of the child. To make 00073 // this possible, the parent node must be passed in to the 00074 // constructors of the SoChildList class. 00075 // 00077 00078 class SoAction; 00079 class AuditorsContainer; 00084 { 00085 public: 00086 // Constructors and destructor. 00087 SoChildList(SoNode *parentNode); 00088 SoChildList(SoNode *parentNode, int size); 00089 SoChildList(SoNode *parentNode, const SoChildList &l); 00090 virtual ~SoChildList(); 00091 00092 // All of these override the standard SoBaseList methods so they 00093 // can maintain auditors correctly. 00094 void append(SoNode * child); 00095 void insert(SoNode *child, int addBefore); 00096 void remove(int which); 00097 void truncate(int start); 00098 void copy(const SoChildList &l); 00099 void set(int i, SoNode *child); 00100 00101 // Traverses all children to apply action. Stops if action's 00102 // termination condition is reached 00103 void traverse(SoAction *action); 00104 00105 // Traverses just one child 00106 void traverse(SoAction *action, int childIndex) 00107 { traverse(action, childIndex, childIndex); } 00108 00109 // Traverses all children between two indices, inclusive. Stops if 00110 // action's termination condition is reached. 00111 void traverse(SoAction *action, int firstChild, int lastChild); 00112 00113 // Traverses just one node 00114 void traverse(SoAction *action, SoNode *node); 00115 00116 // multi-instance traversals 00117 // Traverses all children to apply action. Stops if action's 00118 // termination condition is reached for one instance 00119 void traverseMI(SoAction *action, int instanceIndex); 00120 00121 // Traverses just one child with multi instancing 00122 void traverseMI( SoAction *action, int childIndex, int numInstances ) 00123 { traverseMI(action, childIndex, childIndex, numInstances); } 00124 00125 // Traverses all children between two indices, inclusive. Stops if 00126 // action's termination condition is reached. 00127 void traverseMI(SoAction *action, int firstChild, int lastChild, int instanceIndex ); 00128 00129 // Traverses just one node 00130 void traverseMI(SoAction *action, SoNode *node, int instanceIndex ); 00131 00132 private: 00133 // SoPath calls these to be notified of changes in scene graph 00134 // topology: 00135 // moved to the .cxx 00136 void addPathAuditor(SoPath *p); 00137 void removePathAuditor(SoPath *p); 00138 void removeAllPathAuditor(); 00139 static void exitClass(); 00140 00141 private: 00142 00143 // Inner clas that describes current notification info details. 00144 class SoChildNotificationInfo 00145 { 00146 public: 00147 // Constructor. 00148 SoChildNotificationInfo() 00149 { 00150 reset(); 00151 } 00152 // reset current notification details. 00153 inline void reset() 00154 { 00155 m_changedChild = NULL; 00156 m_changedIndex = -1; 00157 m_changeType = SoDataSensor::UNSPECIFIED; 00158 } 00159 // set current notification infos. 00160 inline void set(SoNode* changedChild, const int changedIndex, const SoDataSensor::ChangeType changeType) 00161 { 00162 m_changedChild = changedChild; 00163 m_changedIndex = changedIndex; 00164 m_changeType = changeType; 00165 } 00166 // Basic accessors 00167 inline SoNode* getChangedChild() const 00168 { return m_changedChild; } 00169 int getChangedIndex() const 00170 { return m_changedIndex; } 00171 SoDataSensor::ChangeType getChangeType() const 00172 { return m_changeType;} 00173 00174 private: 00175 // pointer on the changed child 00176 SoNode* m_changedChild; 00177 // index of the changed child 00178 int m_changedIndex; 00179 // current type of changed 00180 SoDataSensor::ChangeType m_changeType; 00181 }; 00182 00183 SoNode* parent; 00184 // This is a container of SoPath* and not a PathList because PathList ref()s the 00185 // paths it contains, and that screws up Path reference counting. 00186 AuditorsContainer *m_auditors; 00187 00188 // Returns details of change (only valid during notification) 00189 const SoChildNotificationInfo& getChildNotificationInfo() const 00190 { return m_childNotificationInfo; } 00191 00192 // keep track of last change during notification process 00193 SoChildNotificationInfo m_childNotificationInfo; 00194 00195 friend class SoNode; 00196 friend class SoDataSensor; 00197 }; 00198 00199 #endif /* _SO_CHILD_LIST_ */ 00200 00201 00202