SoField.h Source File

| http://www.sim.no/ http://www.coin3d.org/

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

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
30 class SbString;
31 class SoEngineOutput;
32 class SoFieldContainer;
33 class SoFieldConverter;
34 class SoFieldList;
35 class SoInput;
36 class SoOutput;
37
38 class COIN_DLL_API SoField {
39
40 public:
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
136 protected:
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
148 private:
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
SoOutput
The SoOutput class is an abstraction of an output stream.SoOutput offers the ability to write basic t...
Definition: SoOutput.h:42
SoFieldContainer
The SoFieldContainer class is a base class for all classes that contain fields.The classes containing...
Definition: SoFieldContainer.h:34
SoField
The SoField class is the top-level abstract base class for fields.Fields is the mechanism used throug...
Definition: SoField.h:38
SoFieldConverter
The SoFieldConverter class is the abstract base class for field converters.When fields of different t...
Definition: SoFieldConverter.h:32
SoEngineOutput
The SoEngineOutput class is the output slots in SoEngine instances.SoEngineOutput has methods for con...
Definition: SoEngineOutput.h:36
SoInput
The SoInput class is an abstraction of file import functionality.This class takes care of most of the...
Definition: SoInput.h:52
SoField::evaluate
void evaluate(void) const
Definition: SoField.h:131
SoFieldList
The SoFieldList class is a container for pointers to SoField objects.
Definition: SoFieldList.h:31
SbString
The SbString class is a string class with convenience functions for string operations.This is the class used for storing and working with character strings. It automatically takes care of supporting all the "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:42
SoNotList
The SoNotList class is a list of SoNotRec notification records.
Definition: SoNotification.h:34
SoType
The SoType class is the basis for the run-time type system in Coin.Many of the classes in the Coin li...
Definition: SoType.h:50
SbName
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
SoNotRec::Type
Type
Definition: SoNotRec.h:35

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