Debian Codegraph @

lib/database/src/so/fields/SoSFNode.c++

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoSFNode
47 |
48 | Author(s) : Paul S. Strauss
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/
55 #include <Inventor/nodes/SoNode.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNode.h`/
56 #include <Inventor/actions/SoWriteAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoWriteAction.h`/
57 #include <Inventor/fields/SoSFNode.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoSFNode.h`/
58
59 //////////////////////////////////////////////////////////////////////////////
60 //
61 // SoSFNode class - contains a pointer to an SoNode. This has to
62 // implement some extra node bookkeeping.
63 //
64 //////////////////////////////////////////////////////////////////////////////
65
66 // Use standard definitions of required methods, but we have to
67 // redefine the rest to keep track of references and auditors.
68
69 SO_SFIELD_REQUIRED_SOURCEcxx . . $ `lib/database/include/Inventor/fields/SoSubField.h:459:9`!(SoSFNode);
70
71 ////////////////////////////////////////////////////////////////////////
72 //
73 // Description:
74 // Constructor
75 //
76 // Use: public
77
78 SoSFNodecxx . . $ SoSFNode#::SoSFNodecxx . . $ SoSFNode#SoSFNode(49f6e7a06ebc5aa8).()
79 //
80 ////////////////////////////////////////////////////////////////////////
81 {
82 // This will prevent treating random memory as an SoNode
83 valuecxx . . $ SoSFNode#value. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
84 }
85
86 ////////////////////////////////////////////////////////////////////////
87 //
88 // Description:
89 // Destructor
90 //
91 // Use: public
92
93 SoSFNodecxx . . $ SoSFNode#::~cxx . . $ SoSFNode#`~SoSFNode`(49f6e7a06ebc5aa8).SoSFNodecxx . . $ SoSFNode#()
94 //
95 ////////////////////////////////////////////////////////////////////////
96 {
97 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
98 valuecxx . . $ SoSFNode#value.->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
99 valuecxx . . $ SoSFNode#value.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
100 }
101 }
102
103 ////////////////////////////////////////////////////////////////////////
104 //
105 // Description:
106 // Sets value to given node pointer.
107 //
108 // Use: public
109
110 void
111 SoSFNodecxx . . $ SoSFNode#::setValuecxx . . $ SoSFNode#setValue(da6c7544ccee32bd).(SoNodecxx . . $ SoNode# *newValue)
112 //
113 ////////////////////////////////////////////////////////////////////////
114 {
115 setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).(newValue);
116 valueChangedcxx . . $ SoField#valueChanged(d4f767463ce0a6b3).();
117 }
118
119 ////////////////////////////////////////////////////////////////////////
120 //
121 // Description:
122 // Equality test. (Standard definition.)
123 //
124 // Use: public
125
126 int
127 SoSFNodecxx . . $ SoSFNode#::operatorcxx . . $ SoSFNode#`operator==`(9e765775bbb366fe). ==(const SoSFNodecxx . . $ SoSFNode# &f) const
128 //
129 ////////////////////////////////////////////////////////////////////////
130 {
131 return getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).() == f.getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).();
132 }
133
134 ////////////////////////////////////////////////////////////////////////
135 //
136 // Description:
137 // Reads value from file. Returns FALSE on error.
138 //
139 // Use: private
140
141 SbBoolcxx . . $ SbBool#
142 SoSFNodecxx . . $ SoSFNode#::readValuecxx . . $ SoSFNode#readValue(cfb31f743f00c8ca).(SoInputcxx . . $ SoInput# *in)
143 //
144 ////////////////////////////////////////////////////////////////////////
145 {
146 SbNamecxx . . $ SbName# namecxx . . $ SbName#SbName(49f6e7a06ebc5aa8).;
147 SoBasecxx . . $ SoBase# *base;
148
149 // See if it's a null pointer
150 if (in->readcxx . . $ SoInput#read(9a8a621633966675).(name)) {
151 if (name ==cxx . . $ `operator==`(1deca42c6f82b65f). "NULL") {
152 setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
153 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
154 }
155 else
156 in->putBackcxx . . $ SoInput#putBack(85c52e162fed56f9).(name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).());
157 }
158
159 // Read node
160 if (! SoBasecxx . . $ SoBase#::readcxx . . $ SoBase#read(56c2a128ec952e80).(in, base, SoNodecxx . . $ SoNode#::getClassTypeIdcxx . . $ SoNode#getClassTypeId(c00c150378d2b968).())) {
161 setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
162 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
163 }
164
165 setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).((SoNodecxx . . $ SoNode# *) base);
166
167 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
168 }
169
170 ////////////////////////////////////////////////////////////////////////
171 //
172 // Description:
173 // Overrides SoField::countWriteRefs() to maintain write-references
174 // in node.
175 //
176 // Use: private
177
178 void
179 SoSFNodecxx . . $ SoSFNode#::countWriteRefscxx . . $ SoSFNode#countWriteRefs(58762e0f79576b7c).(SoOutputcxx . . $ SoOutput# *out) const
180 //
181 ////////////////////////////////////////////////////////////////////////
182 {
183 // Do standard counting for field
184 SoFieldcxx . . $ SoField#::countWriteRefscxx . . $ SoField#countWriteRefs(58762e0f79576b7c).(out);
185
186 // Count node
187 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
188 valuecxx . . $ SoSFNode#value.->writeInstancecxx . . $ SoNode#writeInstance(46d85c4d426f339d).(out);
189 }
190
191 ////////////////////////////////////////////////////////////////////////
192 //
193 // Description:
194 // Writes value of field to file.
195 //
196 // Use: private
197
198 void
199 SoSFNodecxx . . $ SoSFNode#::writeValuecxx . . $ SoSFNode#writeValue(58762e0f79576b7c).(SoOutputcxx . . $ SoOutput# *out) const
200 //
201 ////////////////////////////////////////////////////////////////////////
202 {
203 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
204 valuecxx . . $ SoSFNode#value.->writeInstancecxx . . $ SoNode#writeInstance(46d85c4d426f339d).(out);
205 else
206 out->writecxx . . $ SoOutput#write(85c52e162fed56f9).("NULL");
207 }
208
209 ////////////////////////////////////////////////////////////////////////
210 //
211 // Description:
212 // Changes value in field without doing other notification stuff.
213 // Keeps track of references and auditors.
214 //
215 // Use: private
216
217 void
218 SoSFNodecxx . . $ SoSFNode#::setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).(SoNodecxx . . $ SoNode# *newValue)
219 //
220 ////////////////////////////////////////////////////////////////////////
221 {
222 // Play it safe if we are replacing one pointer with the same pointer
223 if (newValue != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
224 newValue->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
225
226 // Get rid of old node, if any
227 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
228 valuecxx . . $ SoSFNode#value.->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
229 valuecxx . . $ SoSFNode#value.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
230 }
231
232 valuecxx . . $ SoSFNode#value. = newValue;
233
234 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
235 valuecxx . . $ SoSFNode#value.->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
236 valuecxx . . $ SoSFNode#value.->addAuditorcxx . . $ SoBase#addAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
237 }
238
239 if (newValue != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
240 newValue->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
241 }
242
243 ////////////////////////////////////////////////////////////////////////
244 //
245 // Description:
246 // Update a copied field to use the copy of the node if there is
247 // one.
248 //
249 // Use: internal
250
251 void
252 SoSFNodecxx . . $ SoSFNode#::fixCopycxx . . $ SoSFNode#fixCopy(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# copyConnections)
253 //
254 ////////////////////////////////////////////////////////////////////////
255 {
256 if (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
257 SoNodecxx . . $ SoNode# *nodeCopy = (SoNodecxx . . $ SoNode# *)
258 SoFieldContainercxx . . $ SoFieldContainer#::findCopycxx . . $ SoFieldContainer#findCopy(764c84fe9fa40e97).(valuecxx . . $ SoSFNode#value., copyConnections);
259 if (nodeCopy != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
260 setValcxx . . $ SoSFNode#setVal(da6c7544ccee32bd).(nodeCopy);
261 }
262 }
263
264 ////////////////////////////////////////////////////////////////////////
265 //
266 // Description:
267 // Override this to also check the stored node.
268 //
269 // Use: internal, virtual
270
271 SbBoolcxx . . $ SbBool#
272 SoSFNodecxx . . $ SoSFNode#::referencesCopycxx . . $ SoSFNode#referencesCopy(455f465bc33b4cdf).() const
273 //
274 ////////////////////////////////////////////////////////////////////////
275 {
276 // Do the normal test, and also see if the stored node is a copy
277 return (SoSFieldcxx . . $ SoSField#::referencesCopycxx . . $ SoField#referencesCopy(455f465bc33b4cdf).() ||
278 (valuecxx . . $ SoSFNode#value. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && SoFieldContainercxx . . $ SoFieldContainer#::checkCopycxx . . $ SoFieldContainer#checkCopy(39a6da8fb59a7efc).(valuecxx . . $ SoSFNode#value.) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!));
279 }