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) 1998-2007 by Systems in Motion. All rights reserved.
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 Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, 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
46 void setIgnored(SbBool ignore);
47 SbBool isIgnored(void) const;
48
49 void setDefault(SbBool def);
50 SbBool isDefault(void) const;
51
52 virtual SoType getTypeId(void) const = 0;
53
54 static SoType getClassTypeId(void);
55 SbBool isOfType(const SoType type) const;
56
57 void enableConnection(SbBool flag);
58 SbBool isConnectionEnabled(void) const;
59
60 // Field<-Engine connection stuff.
61 SbBool connectFrom(SoEngineOutput * master,
62 SbBool notnotify = FALSE, SbBool append = FALSE);
63 SbBool appendConnection(SoEngineOutput * master, SbBool notnotify = FALSE);
64 void disconnect(SoEngineOutput * engineoutput);
65 SbBool isConnectedFromEngine(void) const;
66 SbBool getConnectedEngine(SoEngineOutput *& master) const;
67
68 // Field<->Field connection stuff.
69 SbBool connectFrom(SoField * master,
70 SbBool notnotify = FALSE, SbBool append = FALSE);
71 SbBool appendConnection(SoField * master, SbBool notnotify = FALSE);
72 void disconnect(SoField * field);
73 SbBool isConnectedFromField(void) const;
74 SbBool getConnectedField(SoField *& master) const;
75 int getNumConnections(void) const;
76 int getForwardConnections(SoFieldList & slavelist) const;
77 int getConnections(SoFieldList & masterlist) const;
78
79 void disconnect(void);
80 SbBool isConnected(void) const;
81
82 void setContainer(SoFieldContainer * cont);
83 SoFieldContainer * getContainer(void) const;
84
85 SbBool set(const char * valuestring);
86 void get(SbString & valuestring);
87
88 SbBool shouldWrite(void) const;
89
90 virtual void touch(void);
91 virtual void startNotify(void);
92 virtual void notify(SoNotList * nlist);
93 SbBool enableNotify(SbBool on);
94 SbBool isNotifyEnabled(void) const;
95
96 void addAuditor(void * f, SoNotRec::Type type);
97 void removeAuditor(void * f, SoNotRec::Type type);
98
99 int operator ==(const SoField & f) const;
100 int operator !=(const SoField & f) const;
101
102 virtual void connectionStatusChanged(int numconnections);
103 SbBool isReadOnly(void) const;
104 virtual SbBool isSame(const SoField & f) const = 0;
105 virtual void copyFrom(const SoField & f) = 0;
106
107 virtual void fixCopy(SbBool copyconnections);
108 virtual SbBool referencesCopy(void) const;
109 void copyConnection(const SoField * fromfield);
110
111 virtual SbBool read(SoInput * in, const SbName & name);
112 virtual void write(SoOutput * out, const SbName & name) const;
113
114 virtual void countWriteRefs(SoOutput * out) const;
115
116 // enums for setFieldType()/getFieldType()
117 enum FieldType {
118 NORMAL_FIELD = 0,
119 EVENTIN_FIELD,
120 EVENTOUT_FIELD,
121 EXPOSED_FIELD
122 };
123
124 void setFieldType(int type);
125 int getFieldType(void) const;
126
127 SbBool getDirty(void) const;
128 void setDirty(SbBool dirty);
129
130 void evaluate(void) const {
131 if ((this->statusbits & (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) ==
132 (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) this->evaluateField();
133 }
134
135protected:
136 SoField(void);
137
138 void valueChanged(SbBool resetdefault = TRUE);
139 virtual void evaluateConnection(void) const;
140 virtual SbBool readValue(SoInput * in) = 0;
141 virtual void writeValue(SoOutput * out) const = 0;
142 virtual SbBool readConnection(SoInput * in);
143 virtual void writeConnection(SoOutput * out) const;
144
145 SbBool isDestructing(void) const;
146
147private:
148
149 enum FieldFlags {
150 FLAG_TYPEMASK = 0x0007, // need 3 bits for values [0-5]
151 FLAG_ISDEFAULT = 0x0008,
152 FLAG_IGNORE = 0x0010,
153 FLAG_EXTSTORAGE = 0x0020,
154 FLAG_ENABLECONNECTS = 0x0040,
155 FLAG_NEEDEVALUATION = 0x0080,
156 FLAG_READONLY = 0x0100,
157 FLAG_DONOTIFY = 0x0200,
158 FLAG_ISDESTRUCTING = 0x0400,
159 FLAG_ISEVALUATING = 0x0800,
160 FLAG_ISNOTIFIED = 0x1000
161 };
162
163 void evaluateField(void) const;
164 void extendStorageIfNecessary(void);
165 SoFieldConverter * createConverter(SoType from) const;
166 SoFieldContainer * resolveWriteConnection(SbName & mastername) const;
167
168 void notifyAuditors(SoNotList * l);
169
170 static SoType classTypeId;
171
172 // These are bit flags.
173 enum FileFormatFlags {
174 IGNORED = 0x01,
175 CONNECTED = 0x02,
176 DEFAULT = 0x04,
177 ALLFILEFLAGS = IGNORED|CONNECTED|DEFAULT
178 };
179
180 SbBool changeStatusBits(const unsigned int bits, const SbBool onoff);
181 void clearStatusBits(const unsigned int bits);
182 void setStatusBits(const unsigned int bits);
183 SbBool getStatus(const unsigned int bits) const;
184 unsigned int statusbits;
185 union {
186 SoFieldContainer * container;
187 class SoConnectStorage * storage;
188 };
189
190 SbBool hasExtendedStorage(void) const;
191};
192
193
194#ifndef COIN_INTERNAL
195// Added to be Inventor compliant.
196#include <Inventor/fields/SoSField.h>
197#include <Inventor/fields/SoMField.h>
198#endif // !COIN_INTERNAL
199
200#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:35
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
void evaluate(void) const
Definition: SoField.h:130
virtual SoType getTypeId(void) const =0
virtual void writeValue(SoOutput *out) const =0
virtual void copyFrom(const SoField &f)=0
virtual SbBool readValue(SoInput *in)=0
The SoInput class is an abstraction of file import functionality.
Definition: SoInput.h:55
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-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 20 2022 for Coin by Doxygen. 1.9.4