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 ** Modified by : Nick Thompson (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_NOTIFICATION_ 00052 #define _SO_NOTIFICATION_ 00053 00054 #include <Inventor/SbBasic.h> 00055 00056 class SoBase; 00057 class SoField; 00058 class SoEngineOutput; 00059 class SoVRMLInterpOutput; 00060 00062 // 00063 // Class: SoNotRec 00064 // 00065 // Records one step in the path taken by notification. Instances of 00066 // this class are typically allocated on the stack as automatic 00067 // variables. 00068 // 00069 // There is an SoBase pointer in the record that points to the base 00070 // (node, path, engine, interpolator) from which the notification is being 00071 // propagated. The contents of this pointer depend on the type of 00072 // the notification. The type also indicates the nature of the 00073 // notification. These are the possible types: 00074 // 00075 // CONTAINER: A field has changed value and is notifying its 00076 // container node or engine. The base is the container. 00077 // 00078 // PARENT: A child of a group has changed and is notifying 00079 // its parent. The base is the child. 00080 // 00081 // SENSOR: A node or path is notifying a sensor of a change. 00082 // The base is the thing to which the sensor is attached. 00083 // 00084 // FIELD: A field in a node or engine is notifying the 00085 // field to which it is connected. The base is the 00086 // container of the source field. 00087 // 00088 // ENGINE: An engine is notifying a field to which it is 00089 // connected. The base is the engine. 00090 // 00091 // UNDEFINED: None or undefined notification type. 00092 // 00094 00095 { 00096 00097 public: 00098 00099 // Notification types (what receives notification). Note that 00100 // these are also used for maintaining lists of auditors in 00101 // SoBase instances. Each auditor uses one of these types to 00102 // indicate how it is auditing the instance. This is then 00103 // propagated to the auditors in the notification records. 00104 enum Type { 00105 CONTAINER, // Field notifying container 00106 PARENT, // Child node notifying parent 00107 SENSOR, // Some base notifying sensor 00108 FIELD, // Field notifying connected field 00109 ENGINE, // Engine notifying connected field 00110 INTERP, // VRMLInterpolator notifying connected field 00111 ELEMENT, // Element notifying container 00112 UNDEFINED // none or undefined 00113 }; 00114 00115 // Constructor - passed the base pointer 00116 SoNotRec(SoBase *b) { base = b; } 00117 00118 // Sets notification type 00119 void setType(SoNotRec::Type t) { type = t; } 00120 00121 // Returns base pointer, type, or previous record in list 00122 SoBase * getBase() const { return base; } 00123 SoNotRec::Type getType() const { return type; } 00124 const SoNotRec * getPrevious() const { return previous; } 00125 00126 // Sets previous record pointer 00127 void setPrevious(SoNotRec *prev) { previous = prev; } 00128 00129 // Prints a notification record for debugging 00130 void print(FILE *fp) const; 00131 00132 private: 00133 00134 SoBase *base; // Base that changed 00135 Type type; // Type of record 00136 const SoNotRec *previous; // Pointer to previous record 00137 }; 00138 00140 // 00141 // Class: SoNotList 00142 // 00143 // Holds a list of SoNotRec notification records. Points to the first 00144 // and last records in the list. The records are linked backwards by 00145 // "previous" pointers. 00146 // 00147 // The list also points to the first notification record that 00148 // involves a node. This info is used to determine which node 00149 // actually notified sensors. There is also a pointer to the last 00150 // field that changed, which is needed by field-specific sensors. 00151 // 00153 00154 { 00155 00156 public: 00157 // Constructor 00158 SoNotList(); 00159 00160 // Copy constructor 00161 SoNotList(const SoNotList* copyFrom); 00162 00163 // Appends given non-field record to end of list. 00164 void append(SoNotRec *rec); 00165 00166 // Appends given (container) field record to end of list. We 00167 // assume the base in the record is a node. 00168 void append(SoNotRec *rec, SoField *field); 00169 00170 // Appends given (container) engineOutput record to end of list. We 00171 // assume the base in the record is a node. 00172 void append(SoNotRec *rec, SoEngineOutput *engineOutput); 00173 00174 // Appends given (container) interpOutput record to end of list. We 00175 // assume the base in the record is a node. 00176 void append(SoNotRec *rec, SoVRMLInterpOutput *interpOutput); 00177 00178 // Sets the type of the last (current) record in the list 00179 void setLastType(SoNotRec::Type t) 00180 { 00181 last->setType(t); 00182 // Reset firstAtNode pointer if we're going through 00183 // field-to-field or engine-to-field connections. 00184 if (t == SoNotRec::FIELD || 00185 t == SoNotRec::ENGINE || 00186 t == SoNotRec::INTERP) 00187 firstAtNode = NULL; 00188 } 00189 00191 SoNotRec * getFirstRec() const { return first; } 00192 00194 SoNotRec * getLastRec() const { return last; } 00195 00196 // Returns first record in list that has a node base in the 00197 // current chain of node-to-node notification. This information is 00198 // passed to sensor callbacks to indicate which node initiated 00199 // notification in the graph. 00200 SoNotRec * getFirstRecAtNode() const { return firstAtNode; } 00201 00202 // Returns last field set by notification (or NULL if notification 00203 // did not originate at or propagate through a field) 00204 SoField * getLastField() const { return lastField; } 00205 00206 // Returns last Interpolator Output set by notification 00207 // (or NULL if notification did not originate at or propagate 00208 //through a field) 00209 SoVRMLInterpOutput * getLastInterpOutput() const 00210 { return lastInterpOutput; } 00211 00212 // Returns last Engine Output set by notification 00213 // (or NULL if notification did not originate at or propagate 00214 //through a field) 00215 SoEngineOutput * getLastEngineOutput() const { return lastEngineOutput; } 00216 00217 00218 // Returns the time stamp so nodes can check if notification has 00219 // already been handled 00220 uint64_t getTimeStamp() const { return timeStamp; } 00221 00222 // Should be called by a node or field when it broke its internal cache so that other 00223 // nodes of notList are aware someone broke its cache. 00224 void setCacheBroken() { m_cacheAlreadyBroken = true; } 00225 00226 // True if some nodes or field broke its cache during notification propagation. 00227 bool isCacheAlreadyBroken() const { return m_cacheAlreadyBroken; } 00228 00229 // Prints a notification list for debugging 00230 void print(FILE *fp) const; 00231 00232 private: 00233 SoNotRec *first, *last; // First and last records in list 00234 SoNotRec *firstAtNode; // First record that has a node base 00235 SoField *lastField; // Last field that changed 00236 SoVRMLInterpOutput *lastInterpOutput; // Last field that changed 00237 SoEngineOutput *lastEngineOutput; // Last field that changed 00238 uint64_t timeStamp; // Time stamp of notification 00239 00240 // true if someone, field, node, whatever, broke its cache during notification. 00241 // In this case, following notified node should also break their cache. 00242 bool m_cacheAlreadyBroken; 00243 }; 00244 00245 #endif /* _SO_NOTIFICATION_ */ 00246 00247 00248