Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoEngine.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 : Gavin Bell (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_ENGINE_
51#define _SO_ENGINE_
52
53#include <Inventor/SbBasic.h>
54#include <Inventor/fields/SoFieldContainer.h>
55#include <Inventor/SoLists.h>
56#include <Inventor/SbString.h>
57#include <Inventor/SoType.h>
58
60//
61// Class: SoEngine
62//
63// Base SoEngine class (abstract).
64//
66
67
68class SoFieldData;
69class SoEngineList;
70class SoEngineOutput;
72class SoEngineOutputData;
73class SoField;
74class SoOutput;
75class SoInput;
76
134
135 public:
136
141
147 virtual int getOutputs(SoEngineOutputList &list) const;
148
153 SoEngineOutput * getOutput(const SbName &outputName) const;
154
160 SbName &outputName) const;
161
166 SoEngine * copy() const;
167
171 static SoEngine * getByName(const SbName &name);
175 static int getByName(const SbName &name, SoEngineList &list);
176
177 private:
178
182 virtual void evaluate() = 0;
183
184 private:
185
186 // wrapper for the user's evaluate() engine
187 void evaluateWrapper();
188
189 // Propagates modification notification through an instance.
190 virtual void notify(SoNotList *list);
191
192 // Initializes base engine class
193 static void initClass();
194 static void exitClass();
195
196 // Info on outputs:
197 virtual const SoEngineOutputData *getOutputData() const = 0;
198
199 // Initialize ALL Inventor engine classes
200 static void initClasses();
201 static void exitClasses();
202
203 // Writes instance to SoOutput. (Used only for last stage of writing)
204 virtual void writeInstance(SoOutput *out);
205
206 // Copies an instance that is encountered through a field connection
207 virtual SoFieldContainer * copyThroughConnection() const;
208
209 // Recursive procedure that determines if this engine should be
210 // copied during a copy operation, or just referenced as is
211 SbBool shouldCopy() const;
212
213 // A very annoying double notification occurs with engines
214 // that enable their outputs during inputChanged; this flag
215 // prevents that:
216 SbBool isNotifying() const { return notifying; }
217
218 private:
219
220 // Constructor, destructor
221 SoEngine();
222 virtual ~SoEngine();
223
224 // Reads stuff into instance. Returns FALSE on error
225 virtual SbBool readInstance(SoInput *in, unsigned short flags);
226
227 // This is called whenever the value of an input is changed. The
228 // default method does nothing. Subclasses can override this to
229 // detect when a specific field is changed.
230 virtual void inputChanged(SoField *whichField);
231
232 // This is used by the input&output inheritence mechanism, hidden in
233 // the SoSubEngine macros
234 static const SoFieldData **getInputDataPtr() { return NULL; }
235 static const SoEngineOutputData **getOutputDataPtr() { return NULL; }
236
237 // Write output type information for engines that are not built-in.
238 void writeOutputTypes(SoOutput *out);
239
240 private:
241
242 static SoType classTypeId;
243 SbBool needsEvaluation; // Dirty bit
244 SbBool notifying;
245 friend class SoEngineOutput;
246};
247
249//
250// Class: SoEngineOutput
251//
252// Engine outputs. They are lists of fields to be written into,
253// and a pointer back to the containing engine.
254//
256
280
281 public:
286
292
297 void enable(SbBool flag);
301 SbBool isEnabled() const { return enabled; }
302
306 SoEngine * getContainer() const { return container; }
307
310 { return connections.getLength(); }
311
312private:
313
316
318 virtual ~SoEngineOutput();
319
320private:
321 void setContainer(SoEngine *eng) { container = eng; }
322
323 // Adds/removes connection to field
324 void addConnection(SoField *);
325 void removeConnection(SoField *);
326
327 // Returns the fields this output is writing into
328 SoField * operator[](int i) const
329 { return connections.get(i); }
330
331 // Before evaluating (which is done with the regular field API),
332 // we must disable notification on all the fields we're about to
333 // write into. After evaluating, the bits are restored:
334 void prepareToWrite() const;
335 void doneWriting() const;
336
337 private:
338 SbBool enabled;
339 SoFieldList connections;
340 SoEngine *container;
341};
342
343#endif /* _SO_ENGINE_ */
344
345
346
Character string stored in a hash table.
Definition SbName.h:162
int getLength() const
Returns number of pointers in list.
Definition SbPList.h:125
Base class for all engines.
Definition SoEngine.h:133
static SoEngine * getByName(const SbName &name)
Looks up engine(s) by name.
SbBool getOutputName(const SoEngineOutput *output, SbName &outputName) const
Returns (in outputName) the name of the engine output (output).
virtual int getOutputs(SoEngineOutputList &list) const
Returns a list of outputs in this engine.
SoEngine * copy() const
Creates and returns an exact copy of the engine.
SoEngineOutput * getOutput(const SbName &outputName) const
Returns a reference to the engine output with the given name.
static SoType getClassTypeId()
Returns the type identifier for the SoEngine class.
static int getByName(const SbName &name, SoEngineList &list)
Looks up engine(s) by name.
Maintains a list of pointers to engines.
Class for all engine outputs.
Definition SoEngine.h:279
int getNumConnections() const
Number of connections this output currently has.
Definition SoEngine.h:309
SoType getConnectionType() const
Returns the type of field this output can connect to.
SbBool isEnabled() const
Returns TRUE if this output is currently enabled.
Definition SoEngine.h:301
void enable(SbBool flag)
Enables or disables all connections from this output.
SoEngine * getContainer() const
Returns containing engine.
Definition SoEngine.h:306
int getForwardConnections(SoFieldList &list) const
Returns the number of fields this output is writing to, and adds references to those fields to the gi...
Maintains a list of pointers to engine outputs.
Abstract base class for objects that contain fields.
Base class for all fields.
Definition SoField.h:234
Maintains a list of pointers to fields.
Definition SoFieldList.h:72
Used to read Open Inventor data files.
Definition SoInput.h:363
Used to write Open Inventor data files.
Definition SoOutput.h:186
Stores runtime type information.
Definition SoType.h:98
int SbBool
Boolean type.
Definition SbBase.h:87