SoField.h
#ifndef COIN_SOFIELD_H
#define COIN_SOFIELD_H
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
#include <Inventor/SoType.h>
#include <Inventor/misc/SoNotification.h>
class SbString;
class SoEngineOutput;
class SoFieldContainer;
class SoFieldConverter;
class SoFieldList;
class SoInput;
class SoOutput;
class COIN_DLL_API SoField {
public:
virtual ~SoField();
static void initClass(void);
static void initClasses(void);
static void cleanupClass(void);
void setIgnored(SbBool ignore);
SbBool isIgnored(void) const;
void setDefault(SbBool defaultVal);
SbBool isDefault(void) const;
virtual SoType getTypeId(void) const = 0;
static SoType getClassTypeId(void);
SbBool isOfType(const SoType type) const;
void enableConnection(SbBool flag);
SbBool isConnectionEnabled(void) const;
// Field<-Engine connection stuff.
SbBool connectFrom(SoEngineOutput * master,
SbBool notnotify = FALSE, SbBool append = FALSE);
SbBool appendConnection(SoEngineOutput * master, SbBool notnotify = FALSE);
void disconnect(SoEngineOutput * engineoutput);
SbBool isConnectedFromEngine(void) const;
SbBool getConnectedEngine(SoEngineOutput *& master) const;
// Field<->Field connection stuff.
SbBool connectFrom(SoField * master,
SbBool notnotify = FALSE, SbBool append = FALSE);
SbBool appendConnection(SoField * master, SbBool notnotify = FALSE);
void disconnect(SoField * field);
SbBool isConnectedFromField(void) const;
SbBool getConnectedField(SoField *& master) const;
int getNumConnections(void) const;
int getForwardConnections(SoFieldList & slavelist) const;
int getConnections(SoFieldList & masterlist) const;
void disconnect(void);
SbBool isConnected(void) const;
void setContainer(SoFieldContainer * cont);
SoFieldContainer * getContainer(void) const;
SbBool set(const char * valuestring);
void get(SbString & valuestring);
SbBool shouldWrite(void) const;
virtual void touch(void);
virtual void startNotify(void);
virtual void notify(SoNotList * nlist);
SbBool enableNotify(SbBool on);
SbBool isNotifyEnabled(void) const;
void addAuditor(void * f, SoNotRec::Type type);
void removeAuditor(void * f, SoNotRec::Type type);
int operator ==(const SoField & f) const;
int operator !=(const SoField & f) const;
virtual void connectionStatusChanged(int numconnections);
SbBool isReadOnly(void) const;
virtual SbBool isSame(const SoField & f) const = 0;
virtual void copyFrom(const SoField & f) = 0;
virtual void fixCopy(SbBool copyconnections);
virtual SbBool referencesCopy(void) const;
void copyConnection(const SoField * fromfield);
virtual SbBool read(SoInput * input, const SbName & name);
virtual void write(SoOutput * out, const SbName & name) const;
virtual void countWriteRefs(SoOutput * out) const;
// enums for setFieldType()/getFieldType()
enum FieldType {
NORMAL_FIELD = 0,
EVENTIN_FIELD,
EVENTOUT_FIELD,
EXPOSED_FIELD
};
void setFieldType(int type);
int getFieldType(void) const;
SbBool getDirty(void) const;
void setDirty(SbBool dirty);
void evaluate(void) const {
if ((this->statusbits & (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) ==
(FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) this->evaluateField();
}
protected:
SoField(void);
void valueChanged(SbBool resetdefault = TRUE);
virtual void evaluateConnection(void) const;
virtual SbBool readValue(SoInput * in) = 0;
virtual void writeValue(SoOutput * out) const = 0;
virtual SbBool readConnection(SoInput * in);
virtual void writeConnection(SoOutput * out) const;
SbBool isDestructing(void) const;
virtual SoNotRec createNotRec(SoBase * cont);
private:
enum FieldFlags {
FLAG_TYPEMASK = 0x0007, // need 3 bits for values [0-5]
FLAG_ISDEFAULT = 0x0008,
FLAG_IGNORE = 0x0010,
FLAG_EXTSTORAGE = 0x0020,
FLAG_ENABLECONNECTS = 0x0040,
FLAG_NEEDEVALUATION = 0x0080,
FLAG_READONLY = 0x0100,
FLAG_DONOTIFY = 0x0200,
FLAG_ISDESTRUCTING = 0x0400,
FLAG_ISEVALUATING = 0x0800,
FLAG_ISNOTIFIED = 0x1000
};
void evaluateField(void) const;
void extendStorageIfNecessary(void);
SoFieldConverter * createConverter(SoType from) const;
SoFieldContainer * resolveWriteConnection(SbName & mastername) const;
void notifyAuditors(SoNotList * l);
static SoType classTypeId;
// These are bit flags.
enum FileFormatFlags {
IGNORED = 0x01,
CONNECTED = 0x02,
DEFAULT = 0x04,
ALLFILEFLAGS = IGNORED|CONNECTED|DEFAULT
};
SbBool changeStatusBits(const unsigned int bits, const SbBool onoff);
void clearStatusBits(const unsigned int bits);
void setStatusBits(const unsigned int bits);
SbBool getStatus(const unsigned int bits) const;
unsigned int statusbits;
union {
SoFieldContainer * container;
class SoConnectStorage * storage;
};
SbBool hasExtendedStorage(void) const;
};
#ifndef COIN_INTERNAL
// Added to be Inventor compliant.
#include <Inventor/fields/SoSField.h>
#include <Inventor/fields/SoMField.h>
#endif // !COIN_INTERNAL
#endif // !COIN_SOFIELD_H
SbName
The SbName class stores strings by reference.
Definition SbName.h:40
SbString
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:52
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition SoBase.h:45
SoEngineOutput
The SoEngineOutput class is the output slots in SoEngine instances.
Definition SoEngineOutput.h:45
SoFieldContainer
The SoFieldContainer class is a base class for all classes that contain fields.
Definition SoFieldContainer.h:43
SoFieldConverter
The SoFieldConverter class is the abstract base class for field converters.
Definition SoFieldConverter.h:41
SoFieldList
The SoFieldList class is a container for pointers to SoField objects.
Definition SoFieldList.h:40
SoField
The SoField class is the top-level abstract base class for fields.
Definition SoField.h:47
SoField::cleanupClass
static void cleanupClass(void)
Definition SoField.cpp:650
SoField::disconnect
void disconnect(SoEngineOutput *engineoutput)
Definition SoField.cpp:1096
SoField::isSame
virtual SbBool isSame(const SoField &f) const =0
SoField::isNotifyEnabled
SbBool isNotifyEnabled(void) const
Definition SoField.cpp:1588
SoField::setIgnored
void setIgnored(SbBool ignore)
Definition SoField.cpp:668
SoField::isDestructing
SbBool isDestructing(void) const
Definition SoField.cpp:2589
SoField::set
SbBool set(const char *valuestring)
Definition SoField.cpp:1350
SoField::readValue
virtual SbBool readValue(SoInput *in)=0
SoField::evaluate
void evaluate(void) const
Definition SoField.h:140
SoField::copyConnection
void copyConnection(const SoField *fromfield)
Definition SoField.cpp:1795
SoField::startNotify
virtual void startNotify(void)
Definition SoField.cpp:1439
SoField::isConnected
SbBool isConnected(void) const
Definition SoField.cpp:1217
SoField::copyFrom
virtual void copyFrom(const SoField &f)=0
SoField::getClassTypeId
static SoType getClassTypeId(void)
Definition SoField.cpp:727
SoField::getConnectedEngine
SbBool getConnectedEngine(SoEngineOutput *&master) const
Definition SoField.cpp:1280
SoField::getForwardConnections
int getForwardConnections(SoFieldList &slavelist) const
Definition SoField.cpp:1292
SoField::enableNotify
SbBool enableNotify(SbBool on)
Definition SoField.cpp:1574
SoField::connectionStatusChanged
virtual void connectionStatusChanged(int numconnections)
Definition SoField.cpp:1714
SoField::referencesCopy
virtual SbBool referencesCopy(void) const
Definition SoField.cpp:1762
SoField::isOfType
SbBool isOfType(const SoType type) const
Definition SoField.cpp:737
SoField::isConnectionEnabled
SbBool isConnectionEnabled(void) const
Definition SoField.cpp:768
SoField::touch
virtual void touch(void)
Definition SoField.cpp:1427
SoField::getConnectedField
SbBool getConnectedField(SoField *&master) const
Definition SoField.cpp:1266
SoField::connectFrom
SbBool connectFrom(SoEngineOutput *master, SbBool notnotify=FALSE, SbBool append=FALSE)
Definition SoField.cpp:929
SoField::fixCopy
virtual void fixCopy(SbBool copyconnections)
Definition SoField.cpp:1747
SoField::write
virtual void write(SoOutput *out, const SbName &name) const
Definition SoField.cpp:2019
SoField::isConnectedFromEngine
SbBool isConnectedFromEngine(void) const
Definition SoField.cpp:1243
SoField::getConnections
int getConnections(SoFieldList &masterlist) const
Definition SoField.cpp:1183
SoField::notify
virtual void notify(SoNotList *nlist)
Definition SoField.cpp:1464
SoField::getContainer
SoFieldContainer * getContainer(void) const
Definition SoField.cpp:1331
SoField::setContainer
void setContainer(SoFieldContainer *cont)
Definition SoField.cpp:1312
SoField::countWriteRefs
virtual void countWriteRefs(SoOutput *out) const
Definition SoField.cpp:2099
SoField::appendConnection
SbBool appendConnection(SoEngineOutput *master, SbBool notnotify=FALSE)
Definition SoField.cpp:2237
SoField::isConnectedFromField
SbBool isConnectedFromField(void) const
Definition SoField.cpp:1230
SoField::enableConnection
void enableConnection(SbBool flag)
Definition SoField.cpp:755
SoField::initClass
static void initClass(void)
Definition SoField.cpp:627
SoField::read
virtual SbBool read(SoInput *input, const SbName &name)
Definition SoField.cpp:1876
SoField::isReadOnly
SbBool isReadOnly(void) const
Definition SoField.cpp:1727
SoField::removeAuditor
void removeAuditor(void *f, SoNotRec::Type type)
Definition SoField.cpp:1619
SoField::readConnection
virtual SbBool readConnection(SoInput *in)
Definition SoField.cpp:2299
SoField::getTypeId
virtual SoType getTypeId(void) const =0
SoField::SoField
SoField(void)
Definition SoField.cpp:539
SoField::isDefault
SbBool isDefault(void) const
Definition SoField.cpp:716
SoField::get
void get(SbString &valuestring)
Definition SoField.cpp:1369
SoField::setDefault
void setDefault(SbBool defaultVal)
Definition SoField.cpp:693
SoField::initClasses
static void initClasses(void)
Definition SoField.cpp:2609
SoField::getNumConnections
int getNumConnections(void) const
Definition SoField.cpp:1167
SoField::shouldWrite
SbBool shouldWrite(void) const
Definition SoField.cpp:1661
SoField::writeValue
virtual void writeValue(SoOutput *out) const =0
SoField::addAuditor
void addAuditor(void *f, SoNotRec::Type type)
Definition SoField.cpp:1608
SoField::writeConnection
virtual void writeConnection(SoOutput *out) const
Definition SoField.cpp:2402
SoField::isIgnored
SbBool isIgnored(void) const
Definition SoField.cpp:681
SoInput
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:61
SoNotList
The SoNotList class is a list of SoNotRec notification records.
Definition SoNotification.h:43
SoNotRec
The SoNotRec class specifies records for notification lists.
Definition SoNotRec.h:42
SoNotRec::Type
Type
Definition SoNotRec.h:44
SoOutput
The SoOutput class is an abstraction of an output stream.
Definition SoOutput.h:51
SoType
The SoType class is the basis for the runtime type system in Coin.
Definition SoType.h:59