Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoNotification.h
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 S. Strauss (MMM yyyy)
25** Modified by : Nick Thompson (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-2021 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_NOTIFICATION_
52#define _SO_NOTIFICATION_
53
54#include <Inventor/SbBasic.h>
55
56class SoBase;
57class SoField;
58class SoEngineOutput;
59class SoVRMLInterpOutput;
60
62//
63// Class: SoNotRec
64//
65// Records one step in the path taken by notification. Instances of
66// this class are typically allocated on the stack as automatic
67// variables.
68//
69// There is an SoBase pointer in the record that points to the base
70// (node, path, engine, interpolator) from which the notification is being
71// propagated. The contents of this pointer depend on the type of
72// the notification. The type also indicates the nature of the
73// notification. These are the possible types:
74//
75// CONTAINER: A field has changed value and is notifying its
76// container node or engine. The base is the container.
77//
78// PARENT: A child of a group has changed and is notifying
79// its parent. The base is the child.
80//
81// SENSOR: A node or path is notifying a sensor of a change.
82// The base is the thing to which the sensor is attached.
83//
84// FIELD: A field in a node or engine is notifying the
85// field to which it is connected. The base is the
86// container of the source field.
87//
88// ENGINE: An engine is notifying a field to which it is
89// connected. The base is the engine.
90//
91// UNDEFINED: None or undefined notification type.
92//
94
95{
96
97 public:
98
99 // Notification types (what receives notification). Note that
100 // these are also used for maintaining lists of auditors in
101 // SoBase instances. Each auditor uses one of these types to
102 // indicate how it is auditing the instance. This is then
103 // propagated to the auditors in the notification records.
104 enum Type {
105 CONTAINER, // Field notifying container
106 PARENT, // Child node notifying parent
107 SENSOR, // Some base notifying sensor
108 FIELD, // Field notifying connected field
109 ENGINE, // Engine notifying connected field
110 INTERP, // VRMLInterpolator notifying connected field
111 ELEMENT, // Element notifying container
112 UNDEFINED // none or undefined
113 };
114
115 // Constructor - passed the base pointer
116 SoNotRec(SoBase *b) { base = b; }
117
118 // Sets notification type
119 void setType(SoNotRec::Type t) { type = t; }
120
121 // Returns base pointer, type, or previous record in list
122 SoBase * getBase() const { return base; }
123 SoNotRec::Type getType() const { return type; }
124 const SoNotRec * getPrevious() const { return previous; }
125
126 // Sets previous record pointer
127 void setPrevious(SoNotRec *prev) { previous = prev; }
128
129 // Prints a notification record for debugging
130 void print(FILE *fp) const;
131
132 private:
133
134 SoBase *base; // Base that changed
135 Type type; // Type of record
136 const SoNotRec *previous; // Pointer to previous record
137};
138
140//
141// Class: SoNotList
142//
143// Holds a list of SoNotRec notification records. Points to the first
144// and last records in the list. The records are linked backwards by
145// "previous" pointers.
146//
147// The list also points to the first notification record that
148// involves a node. This info is used to determine which node
149// actually notified sensors. There is also a pointer to the last
150// field that changed, which is needed by field-specific sensors.
151//
153
154{
155
156 public:
157 // Constructor
158 SoNotList();
159
160 // Copy constructor
161 SoNotList(const SoNotList* copyFrom);
162
163 // Appends given non-field record to end of list.
164 void append(SoNotRec *rec);
165
166 // Appends given (container) field record to end of list. We
167 // assume the base in the record is a node.
168 void append(SoNotRec *rec, SoField *field);
169
170 // Appends given (container) engineOutput record to end of list. We
171 // assume the base in the record is a node.
172 void append(SoNotRec *rec, SoEngineOutput *engineOutput);
173
174 // Appends given (container) interpOutput record to end of list. We
175 // assume the base in the record is a node.
176 void append(SoNotRec *rec, SoVRMLInterpOutput *interpOutput);
177
178 // Sets the type of the last (current) record in the list
179 void setLastType(SoNotRec::Type t)
180 {
181 last->setType(t);
182 // Reset firstAtNode pointer if we're going through
183 // field-to-field or engine-to-field connections.
184 if (t == SoNotRec::FIELD ||
185 t == SoNotRec::ENGINE ||
186 t == SoNotRec::INTERP)
187 firstAtNode = NULL;
188 }
189
191 SoNotRec * getFirstRec() const { return first; }
192
194 SoNotRec * getLastRec() const { return last; }
195
196 // Returns first record in list that has a node base in the
197 // current chain of node-to-node notification. This information is
198 // passed to sensor callbacks to indicate which node initiated
199 // notification in the graph.
200 SoNotRec * getFirstRecAtNode() const { return firstAtNode; }
201
202 // Returns last field set by notification (or NULL if notification
203 // did not originate at or propagate through a field)
204 SoField * getLastField() const { return lastField; }
205
206 // Returns last Interpolator Output set by notification
207 // (or NULL if notification did not originate at or propagate
208 //through a field)
209 SoVRMLInterpOutput * getLastInterpOutput() const
210 { return lastInterpOutput; }
211
212 // Returns last Engine Output set by notification
213 // (or NULL if notification did not originate at or propagate
214 //through a field)
215 SoEngineOutput * getLastEngineOutput() const { return lastEngineOutput; }
216
217
218 // Returns the time stamp so nodes can check if notification has
219 // already been handled
220 uint64_t getTimeStamp() const { return timeStamp; }
221
222 // Should be called by a node or field when it broke its internal cache so that other
223 // nodes of notList are aware someone broke its cache.
224 void setCacheBroken() { m_cacheAlreadyBroken = true; }
225
226 // True if some nodes or field broke its cache during notification propagation.
227 bool isCacheAlreadyBroken() const { return m_cacheAlreadyBroken; }
228
229 // Prints a notification list for debugging
230 void print(FILE *fp) const;
231
232 private:
233 SoNotRec *first, *last; // First and last records in list
234 SoNotRec *firstAtNode; // First record that has a node base
235 SoField *lastField; // Last field that changed
236 SoVRMLInterpOutput *lastInterpOutput; // Last field that changed
237 SoEngineOutput *lastEngineOutput; // Last field that changed
238 uint64_t timeStamp; // Time stamp of notification
239
240 // true if someone, field, node, whatever, broke its cache during notification.
241 // In this case, following notified node should also break their cache.
242 bool m_cacheAlreadyBroken;
243};
244
245#endif /* _SO_NOTIFICATION_ */
246
247
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Class for all engine outputs.
Definition SoEngine.h:282
Base class for all fields.
Definition SoField.h:234