Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | This file defines the base SoEngine class, and the 00048 | SoEngineOutput class. 00049 | 00050 | Author(s) : Gavin Bell 00051 | 00052 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00053 _______________________________________________________________________ 00054 */ 00055 00056 #ifndef _SO_ENGINE_ 00057 #define _SO_ENGINE_ 00058 00059 #include <Inventor/fields/SoFieldContainer.h> 00060 #include <Inventor/SoLists.h> 00061 #include <Inventor/SbString.h> 00062 #include <Inventor/SoType.h> 00063 00064 00065 00066 class SoFieldData; 00067 class SoEngineList; 00068 class SoEngineOutput; 00069 class SoEngineOutputList; 00070 class SoEngineOutputData; 00071 class SoField; 00072 class SoOutput; 00073 class SoInput; 00074 00077 00100 00101 00102 class INVENTOR_API SoEngine : public SoFieldContainer { 00103 00104 public: 00105 00107 static SoType getClassTypeId() { return classTypeId; } 00108 00113 virtual int getOutputs(SoEngineOutputList &list) const; 00114 00117 SoEngineOutput * getOutput(const SbName &outputName) const; 00118 00122 SbBool getOutputName(const SoEngineOutput *output, 00123 SbName &outputName) const; 00124 00128 SoEngine * copy() const; 00129 00131 static SoEngine * getByName(const SbName &name); 00133 static int getByName(const SbName &name, SoEngineList &list); 00134 00135 protected: 00136 00138 virtual void evaluate() = 0; 00139 00140 SoINTERNAL public: 00141 00143 void evaluateWrapper(); 00144 00146 virtual void notify(SoNotList *list); 00147 00149 static void initClass(); 00150 00152 virtual const SoEngineOutputData *getOutputData() const = 0; 00153 00155 static void initClasses(); 00156 00158 virtual void writeInstance(SoOutput *out); 00159 00161 virtual SoFieldContainer * copyThroughConnection() const; 00162 00165 SbBool shouldCopy() const; 00166 00170 SbBool isNotifying() const { return notifying; } 00171 00172 protected: 00173 00175 SoEngine(); 00176 ~SoEngine(); 00177 00179 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00180 00184 virtual void inputChanged(SoField *whichField); 00185 00188 static const SoFieldData **getInputDataPtr() { return NULL; } 00189 static const SoEngineOutputData **getOutputDataPtr() { return NULL; } 00190 00192 void writeOutputTypes(SoOutput *out); 00193 00194 private: 00195 static SoType classTypeId; 00196 00197 SbBool needsEvaluation; 00198 SbBool notifying; 00199 friend class SoEngineOutput; 00200 }; 00201 00202 00205 00226 00227 00228 class INVENTOR_API SoEngineOutput { 00229 00230 public: 00231 00233 SoType getConnectionType() const; 00234 00237 int getForwardConnections(SoFieldList &list) const; 00238 00242 void enable(SbBool flag); 00244 SbBool isEnabled() const { return enabled; } 00245 00247 SoEngine * getContainer() const { return container; } 00248 00249 SoINTERNAL public: 00250 SoEngineOutput(); 00251 00252 virtual ~SoEngineOutput(); 00253 00254 void setContainer(SoEngine *eng) { container = eng; } 00255 00257 void addConnection(SoField *); 00258 void removeConnection(SoField *); 00259 00261 int getNumConnections() const 00262 { return connections.getLength(); } 00263 00265 SoField * operator[](int i) const 00266 { return connections.get(i); } 00267 00271 void prepareToWrite() const; 00272 void doneWriting() const; 00273 00274 private: 00275 SbBool enabled; 00276 SoFieldList connections; 00277 SoEngine *container; 00278 }; 00279 00280 #endif /* _SO_ENGINE_ */ 00281