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

SoField.h
1#ifndef COIN_SOFIELD_H
2#define COIN_SOFIELD_H
3
4/**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25\**************************************************************************/
26
27#include <Inventor/SoType.h>
28#include <Inventor/misc/SoNotification.h>
29
30class SbString;
31class SoEngineOutput;
34class SoFieldList;
35class SoInput;
36class SoOutput;
37
38class COIN_DLL_API SoField {
39
40public:
41 virtual ~SoField();
42
43 static void initClass(void);
44 static void initClasses(void);
45 static void cleanupClass(void);
46
47 void setIgnored(SbBool ignore);
48 SbBool isIgnored(void) const;
49
50 void setDefault(SbBool defaultVal);
51 SbBool isDefault(void) const;
52
53 virtual SoType getTypeId(void) const = 0;
54
55 static SoType getClassTypeId(void);
56 SbBool isOfType(const SoType type) const;
57
58 void enableConnection(SbBool flag);
59 SbBool isConnectionEnabled(void) const;
60
61 // Field<-Engine connection stuff.
62 SbBool connectFrom(SoEngineOutput * master,
63 SbBool notnotify = FALSE, SbBool append = FALSE);
64 SbBool appendConnection(SoEngineOutput * master, SbBool notnotify = FALSE);
65 void disconnect(SoEngineOutput * engineoutput);
66 SbBool isConnectedFromEngine(void) const;
67 SbBool getConnectedEngine(SoEngineOutput *& master) const;
68
69 // Field<->Field connection stuff.
70 SbBool connectFrom(SoField * master,
71 SbBool notnotify = FALSE, SbBool append = FALSE);
72 SbBool appendConnection(SoField * master, SbBool notnotify = FALSE);
73 void disconnect(SoField * field);
74 SbBool isConnectedFromField(void) const;
75 SbBool getConnectedField(SoField *& master) const;
76 int getNumConnections(void) const;
77 int getForwardConnections(SoFieldList & slavelist) const;
78 int getConnections(SoFieldList & masterlist) const;
79
80 void disconnect(void);
81 SbBool isConnected(void) const;
82
83 void setContainer(SoFieldContainer * cont);
84 SoFieldContainer * getContainer(void) const;
85
86 SbBool set(const char * valuestring);
87 void get(SbString & valuestring);
88
89 SbBool shouldWrite(void) const;
90
91 virtual void touch(void);
92 virtual void startNotify(void);
93 virtual void notify(SoNotList * nlist);
94 SbBool enableNotify(SbBool on);
95 SbBool isNotifyEnabled(void) const;
96
97 void addAuditor(void * f, SoNotRec::Type type);
98 void removeAuditor(void * f, SoNotRec::Type type);
99
100 int operator ==(const SoField & f) const;
101 int operator !=(const SoField & f) const;
102
103 virtual void connectionStatusChanged(int numconnections);
104 SbBool isReadOnly(void) const;
105 virtual SbBool isSame(const SoField & f) const = 0;
106 virtual void copyFrom(const SoField & f) = 0;
107
108 virtual void fixCopy(SbBool copyconnections);
109 virtual SbBool referencesCopy(void) const;
110 void copyConnection(const SoField * fromfield);
111
112 virtual SbBool read(SoInput * input, const SbName & name);
113 virtual void write(SoOutput * out, const SbName & name) const;
114
115 virtual void countWriteRefs(SoOutput * out) const;
116
117 // enums for setFieldType()/getFieldType()
118 enum FieldType {
119 NORMAL_FIELD = 0,
120 EVENTIN_FIELD,
121 EVENTOUT_FIELD,
122 EXPOSED_FIELD
123 };
124
125 void setFieldType(int type);
126 int getFieldType(void) const;
127
128 SbBool getDirty(void) const;
129 void setDirty(SbBool dirty);
130
131 void evaluate(void) const {
132 if ((this->statusbits & (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) ==
133 (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) this->evaluateField();
134 }
135
136protected:
137 SoField(void);
138
139 void valueChanged(SbBool resetdefault = TRUE);
140 virtual void evaluateConnection(void) const;
141 virtual SbBool readValue(SoInput * in) = 0;
142 virtual void writeValue(SoOutput * out) const = 0;
143 virtual SbBool readConnection(SoInput * in);
144 virtual void writeConnection(SoOutput * out) const;
145
146 SbBool isDestructing(void) const;
147
148private:
149
150 enum FieldFlags {
151 FLAG_TYPEMASK = 0x0007, // need 3 bits for values [0-5]
152 FLAG_ISDEFAULT = 0x0008,
153 FLAG_IGNORE = 0x0010,
154 FLAG_EXTSTORAGE = 0x0020,
155 FLAG_ENABLECONNECTS = 0x0040,
156 FLAG_NEEDEVALUATION = 0x0080,
157 FLAG_READONLY = 0x0100,
158 FLAG_DONOTIFY = 0x0200,
159 FLAG_ISDESTRUCTING = 0x0400,
160 FLAG_ISEVALUATING = 0x0800,
161 FLAG_ISNOTIFIED = 0x1000
162 };
163
164 void evaluateField(void) const;
165 void extendStorageIfNecessary(void);
166 SoFieldConverter * createConverter(SoType from) const;
167 SoFieldContainer * resolveWriteConnection(SbName & mastername) const;
168
169 void notifyAuditors(SoNotList * l);
170
171 static SoType classTypeId;
172
173 // These are bit flags.
174 enum FileFormatFlags {
175 IGNORED = 0x01,
176 CONNECTED = 0x02,
177 DEFAULT = 0x04,
178 ALLFILEFLAGS = IGNORED|CONNECTED|DEFAULT
179 };
180
181 SbBool changeStatusBits(const unsigned int bits, const SbBool onoff);
182 void clearStatusBits(const unsigned int bits);
183 void setStatusBits(const unsigned int bits);
184 SbBool getStatus(const unsigned int bits) const;
185 unsigned int statusbits;
186 union {
187 SoFieldContainer * container;
188 class SoConnectStorage * storage;
189 };
190
191 SbBool hasExtendedStorage(void) const;
192};
193
194
195#ifndef COIN_INTERNAL
196// Added to be Inventor compliant.
197#include <Inventor/fields/SoSField.h>
198#include <Inventor/fields/SoMField.h>
199#endif // !COIN_INTERNAL
200
201#endif // !COIN_SOFIELD_H
The SbName class stores strings by reference.
Definition SbName.h:31
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:42
The SoEngineOutput class is the output slots in SoEngine instances.
Definition SoEngineOutput.h:36
The SoFieldContainer class is a base class for all classes that contain fields.
Definition SoFieldContainer.h:34
The SoFieldConverter class is the abstract base class for field converters.
Definition SoFieldConverter.h:32
The SoFieldList class is a container for pointers to SoField objects.
Definition SoFieldList.h:31
The SoField class is the top-level abstract base class for fields.
Definition SoField.h:38
virtual SbBool isSame(const SoField &f) const =0
virtual SbBool readValue(SoInput *in)=0
void evaluate(void) const
Definition SoField.h:131
virtual void copyFrom(const SoField &f)=0
virtual SoType getTypeId(void) const =0
virtual void writeValue(SoOutput *out) const =0
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:52
The SoNotList class is a list of SoNotRec notification records.
Definition SoNotification.h:34
Type
Definition SoNotRec.h:35
The SoOutput class is an abstraction of an output stream.
Definition SoOutput.h:42
The SoType class is the basis for the run-time type system in Coin.
Definition SoType.h:50

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Wed Jul 17 2024 for Coin by Doxygen 1.12.0.