Open Inventor Reference
SoEngine.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the base SoEngine class, and the
48  | SoEngineOutput class.
49  |
50  | Author(s) : Gavin Bell
51  |
52  ______________ S I L I C O N G R A P H I C S I N C . ____________
53  _______________________________________________________________________
54  */
55 
56 #ifndef _SO_ENGINE_
57 #define _SO_ENGINE_
58 
60 #include <Inventor/SoLists.h>
61 #include <Inventor/SbString.h>
62 #include <Inventor/SoType.h>
63 
64 
65 
66 class SoFieldData;
67 class SoEngineList;
68 class SoEngineOutput;
69 class SoEngineOutputList;
70 class SoEngineOutputData;
71 class SoField;
72 class SoOutput;
73 class SoInput;
74 
77 
101 
103 
104  public:
105 
107  static SoType getClassTypeId() { return classTypeId; }
108 
113  virtual int getOutputs(SoEngineOutputList &list) const;
114 
117  SoEngineOutput * getOutput(const SbName &outputName) const;
118 
122  bool getOutputName(const SoEngineOutput *output,
123  SbName &outputName) const;
124 
128  SoEngine * copy() const;
129 
131  static SoEngine * getByName(const SbName &name);
133  static int getByName(const SbName &name, SoEngineList &list);
134 
135  protected:
136 
138  virtual void evaluate() = 0;
139 
140  SoINTERNAL public:
141 
144 
146  virtual void notify(SoNotList *list);
147 
149  static void initClass();
150 
152  virtual const SoEngineOutputData *getOutputData() const = 0;
153 
155  static void initClasses();
156 
158  virtual void writeInstance(SoOutput *out);
159 
162 
165  bool shouldCopy() const;
166 
170  bool isNotifying() const { return notifying; }
171 
172  protected:
173 
177 
179  virtual bool readInstance(SoInput *in, unsigned short flags);
180 
184  virtual void inputChanged(SoField *whichField);
185 
188  static const SoFieldData **getInputDataPtr() { return NULL; }
189  static const SoEngineOutputData **getOutputDataPtr() { return NULL; }
190 
193 
194  private:
195  static SoType classTypeId;
196 
197  bool needsEvaluation;
198  bool notifying;
199 friend class SoEngineOutput;
200 };
201 
202 
205 
227 
229 
230  public:
231 
234 
238 
242  void enable(bool flag);
244  bool isEnabled() const { return enabled; }
245 
247  SoEngine * getContainer() const { return container; }
248 
249  SoINTERNAL public:
251 
252  virtual ~SoEngineOutput();
253 
254  void setContainer(SoEngine *eng) { container = eng; }
255 
259 
261  int getNumConnections() const
262  { return connections.getLength(); }
263 
265  SoField * operator[](int i) const
266  { return connections.get(i); }
267 
271  void prepareToWrite() const;
272  void doneWriting() const;
273 
274  private:
275  bool enabled;
276  SoFieldList connections;
277  SoEngine *container;
278 };
279 
280 #endif /* _SO_ENGINE_ */
281 
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
Character string stored in a hash table.
Definition: SbString.h:264
Maintains a list of pointers to engines.
Definition: SoLists.h:262
The SoEngineOutputData class holds data about engine outputs: the number of outputs the engine has,...
Definition: SoOutputData.h:86
Maintains a list of pointers to engine outputs.
Definition: SoLists.h:471
Class for all engine outputs.
Definition: SoEngine.h:228
int getNumConnections() const
Number of connections this output currently has.
Definition: SoEngine.h:261
SoType getConnectionType() const
Returns the type of field this output can connect to.
void enable(bool flag)
Enables or disables all connections from this ouptut.
void setContainer(SoEngine *eng)
Definition: SoEngine.h:254
void prepareToWrite() const
Before evaluating (which is done with the regular field API), we must disable notification on all the...
bool isEnabled() const
Returns TRUE if this output is currently enabled.
Definition: SoEngine.h:244
virtual ~SoEngineOutput()
SoField * operator[](int i) const
Returns the fields this output is writing into.
Definition: SoEngine.h:265
void doneWriting() const
void removeConnection(SoField *)
int getForwardConnections(SoFieldList &list) const
Returns the number of fields this output is writing to, and adds pointers to those fields to the give...
void addConnection(SoField *)
Adds/removes connection to field.
SoEngine * getContainer() const
Returns containing engine.
Definition: SoEngine.h:247
Base class for all engines.
Definition: SoEngine.h:102
virtual void evaluate()=0
User-written evaluation engine.
static void initClasses()
Initialize ALL Inventor engine classes.
virtual SoFieldContainer * copyThroughConnection() const
Copies an instance that is encountered through a field connection.
SoEngine()
Constructor, destructor.
static const SoFieldData ** getInputDataPtr()
This is used by the input&output inheritence mechanism, hidden in the SoSubEngine macros.
Definition: SoEngine.h:188
virtual void inputChanged(SoField *whichField)
This is called whenever the value of an input is changed.
SoEngine * copy() const
Creates and returns an exact copy of the engine.
virtual void writeInstance(SoOutput *out)
Writes instance to SoOutput. (Used only for last stage of writing)
bool shouldCopy() const
Recursive procedure that determines if this engine should be copied during a copy operation,...
virtual void notify(SoNotList *list)
Propagates modification notification through an instance.
static void initClass()
Initializes base engine class.
void writeOutputTypes(SoOutput *out)
Write output type information for engines that are not built-in.
virtual const SoEngineOutputData * getOutputData() const =0
Info on outputs:
virtual bool readInstance(SoInput *in, unsigned short flags)
Reads stuff into instance. Returns FALSE on error.
void evaluateWrapper()
wrapper for the user's evaluate() engine
virtual int getOutputs(SoEngineOutputList &list) const
Returns a list of outputs in this engine.
bool getOutputName(const SoEngineOutput *output, SbName &outputName) const
Returns (in outputName) the name of the engine output (output).
bool isNotifying() const
A very annoying double notification occurs with engines that enable their outputs during inputChanged...
Definition: SoEngine.h:170
static SoType getClassTypeId()
Returns the type identifier for the SoEngine class.
Definition: SoEngine.h:107
static int getByName(const SbName &name, SoEngineList &list)
Look up engine(s) by name.
static const SoEngineOutputData ** getOutputDataPtr()
Definition: SoEngine.h:189
static SoEngine * getByName(const SbName &name)
Look up engine(s) by name.
SoEngineOutput * getOutput(const SbName &outputName) const
Returns a pointer to the engine output with the given name.
Abstract base class for objects that contain fields.
The SoFieldData class holds data about fields of an object: the number of fields the object has,...
Definition: SoFieldData.h:88
Maintains a list of pointers to fields.
Definition: SoLists.h:426
Base class for all fields.
Definition: SoField.h:185
void get(SbString &valueString)
Returns the value of the field in the Inventor file format, even if the field has its default value.
Used to read Inventor data files.
Definition: SoInput.h:128
Holds a list of SoNotRec notification records.
Used to write Inventor data files.
Definition: SoOutput.h:90
SoType has no virtual functions to keep it small...
Definition: SoType.h:103