Coin Logo http://www.sim.no
http://www.coin3d.org

SoField.h

00001 #ifndef COIN_SOFIELD_H
00002 #define COIN_SOFIELD_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Systems in Motion about acquiring
00018  *  a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/SoType.h>
00028 #include <Inventor/misc/SoNotification.h>
00029 
00030 class SbString;
00031 class SoEngineOutput;
00032 class SoFieldContainer;
00033 class SoFieldConverter;
00034 class SoFieldList;
00035 class SoInput;
00036 class SoOutput;
00037 
00038 class COIN_DLL_API SoField {
00039 
00040 public:
00041   virtual ~SoField();
00042 
00043   static void initClass(void);
00044   static void initClasses(void);
00045 
00046   void setIgnored(SbBool ignore);
00047   SbBool isIgnored(void) const;
00048 
00049   void setDefault(SbBool def);
00050   SbBool isDefault(void) const;
00051 
00052   virtual SoType getTypeId(void) const = 0;
00053 
00054   static SoType getClassTypeId(void);
00055   SbBool isOfType(const SoType type) const;
00056 
00057   void enableConnection(SbBool flag);
00058   SbBool isConnectionEnabled(void) const;
00059 
00060   // Field<-Engine connection stuff.
00061   SbBool connectFrom(SoEngineOutput * master,
00062                      SbBool notnotify = FALSE, SbBool append = FALSE);
00063   SbBool appendConnection(SoEngineOutput * master, SbBool notnotify = FALSE);
00064   void disconnect(SoEngineOutput * engineoutput);
00065   SbBool isConnectedFromEngine(void) const;
00066   SbBool getConnectedEngine(SoEngineOutput *& master) const;
00067 
00068   // Field<->Field connection stuff.
00069   SbBool connectFrom(SoField * master,
00070                      SbBool notnotify = FALSE, SbBool append = FALSE);
00071   SbBool appendConnection(SoField * master, SbBool notnotify = FALSE);
00072   void disconnect(SoField * field);
00073   SbBool isConnectedFromField(void) const;
00074   SbBool getConnectedField(SoField *& master) const;
00075   int getNumConnections(void) const;
00076   int getForwardConnections(SoFieldList & slavelist) const;
00077   int getConnections(SoFieldList & masterlist) const;
00078 
00079   void disconnect(void);
00080   SbBool isConnected(void) const;
00081 
00082   void setContainer(SoFieldContainer * cont);
00083   SoFieldContainer * getContainer(void) const;
00084 
00085   SbBool set(const char * valuestring);
00086   void get(SbString & valuestring);
00087 
00088   SbBool shouldWrite(void) const;
00089 
00090   virtual void touch(void);
00091   virtual void startNotify(void);
00092   virtual void notify(SoNotList * nlist);
00093   SbBool enableNotify(SbBool on);
00094   SbBool isNotifyEnabled(void) const;
00095 
00096   void addAuditor(void * f, SoNotRec::Type type);
00097   void removeAuditor(void * f, SoNotRec::Type type);
00098 
00099   int operator ==(const SoField & f) const;
00100   int operator !=(const SoField & f) const;
00101 
00102   virtual void connectionStatusChanged(int numconnections);
00103   SbBool isReadOnly(void) const;
00104   virtual SbBool isSame(const SoField & f) const = 0;
00105   virtual void copyFrom(const SoField & f) = 0;
00106 
00107   virtual void fixCopy(SbBool copyconnections);
00108   virtual SbBool referencesCopy(void) const;
00109   void copyConnection(const SoField * fromfield);
00110 
00111   virtual SbBool read(SoInput * in, const SbName & name);
00112   virtual void write(SoOutput * out, const SbName & name) const;
00113 
00114   virtual void countWriteRefs(SoOutput * out) const;
00115 
00116   // enums for setFieldType()/getFieldType()
00117   enum FieldType {
00118     NORMAL_FIELD = 0,
00119     EVENTIN_FIELD,
00120     EVENTOUT_FIELD,
00121     EXPOSED_FIELD
00122   };
00123 
00124   void setFieldType(int type);
00125   int getFieldType(void) const;
00126 
00127   SbBool getDirty(void) const;
00128   void setDirty(SbBool dirty);
00129 
00130   void evaluate(void) const {
00131     if ((this->statusbits & (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) == 
00132         (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) this->evaluateField();
00133   }
00134 
00135 protected:
00136   SoField(void);
00137 
00138   void valueChanged(SbBool resetdefault = TRUE);
00139   virtual void evaluateConnection(void) const;
00140   virtual SbBool readValue(SoInput * in) = 0;
00141   virtual void writeValue(SoOutput * out) const = 0;
00142   virtual SbBool readConnection(SoInput * in);
00143   virtual void writeConnection(SoOutput * out) const;
00144 
00145   SbBool isDestructing(void) const;
00146 
00147 private:
00148 
00149   enum FieldFlags {
00150     FLAG_TYPEMASK = 0x0007,  // need 3 bits for values [0-5]
00151     FLAG_ISDEFAULT = 0x0008,
00152     FLAG_IGNORE = 0x0010,
00153     FLAG_EXTSTORAGE = 0x0020,
00154     FLAG_ENABLECONNECTS = 0x0040,
00155     FLAG_NEEDEVALUATION = 0x0080,
00156     FLAG_READONLY = 0x0100,
00157     FLAG_DONOTIFY = 0x0200,
00158     FLAG_ISDESTRUCTING = 0x0400,
00159     FLAG_ISEVALUATING = 0x0800,
00160     FLAG_ISNOTIFIED = 0x1000
00161   };
00162 
00163   void evaluateField(void) const;
00164   void extendStorageIfNecessary(void);
00165   SoFieldConverter * createConverter(SoType from) const;
00166   SoFieldContainer * resolveWriteConnection(SbName & mastername) const;
00167 
00168   void notifyAuditors(SoNotList * l);
00169 
00170   static SoType classTypeId;
00171 
00172   // These are bit flags.
00173   enum FileFormatFlags {
00174     IGNORED = 0x01,
00175     CONNECTED = 0x02,
00176     DEFAULT = 0x04,
00177     ALLFILEFLAGS = IGNORED|CONNECTED|DEFAULT
00178   };
00179 
00180   SbBool changeStatusBits(const unsigned int bits, const SbBool onoff);
00181   void clearStatusBits(const unsigned int bits);
00182   void setStatusBits(const unsigned int bits);
00183   SbBool getStatus(const unsigned int bits) const;
00184   unsigned int statusbits;
00185   union {
00186     SoFieldContainer * container;
00187     class SoConnectStorage * storage;
00188   };
00189 
00190   SbBool hasExtendedStorage(void) const;
00191 };
00192 
00193 
00194 #ifndef COIN_INTERNAL
00195 // Added to be Inventor compliant.
00196 #include <Inventor/fields/SoSField.h>
00197 #include <Inventor/fields/SoMField.h>
00198 #endif // !COIN_INTERNAL
00199 
00200 #endif // !COIN_SOFIELD_H

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 23 16:33:17 2009 for Coin by Doxygen. 1.5.8