Debian Codegraph @

lib/database/src/so/elements/SoElement.c++

raw
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 | SoElement base class.
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
55 #include <Inventor/SoLists.h>
56 #include <Inventor/elements/SoCacheElement.h>
57 #include <Inventor/elements/SoElement.h>
58 #include <Inventor/misc/SoState.h>
59 #include <Inventor/nodes/SoNode.h>
60
61 // Static variables declared in SoElement.h:
62
63 int SoElement::classStackIndex;
64 SoType SoElement::classTypeId;
65 int SoElement::nextStackIndex;
66 SoTypeList *SoElement::stackToType;
67
68 // If we run out of slots in the array of free lists, add this many more
69 #define FREE_LIST_INCREMENT 10
70
71 ////////////////////////////////////////////////////////////////////////
72 //
73 // Description:
74 // Constructor.
75 //
76 // Use: protected
77
78 SoElement::SoElement()
79 //
80 ////////////////////////////////////////////////////////////////////////
81 {
82 }
83
84 ////////////////////////////////////////////////////////////////////////
85 //
86 // Description:
87 // Destructor.
88 //
89 // Use: private
90
91 SoElement::~SoElement()
92 //
93 ////////////////////////////////////////////////////////////////////////
94 {
95 }
96
97 ////////////////////////////////////////////////////////////////////////
98 //
99 // Description:
100 // Initializes element. Default does nothing.
101 //
102 // Use: public
103
104 void
105 SoElement::init(SoState *)
106 //
107 ////////////////////////////////////////////////////////////////////////
108 {
109 }
110
111 ////////////////////////////////////////////////////////////////////////
112 //
113 // Description:
114 // Pushes element. Default does nothing
115 //
116 // Use: public
117
118 void
119 SoElement::push(SoState *)
120 //
121 ////////////////////////////////////////////////////////////////////////
122 {
123 }
124
125 ////////////////////////////////////////////////////////////////////////
126 //
127 // Description:
128 // Pops element. Default does nothing
129 //
130 // Use: public
131
132 void
133 SoElement::pop(SoState *, const SoElement *)
134 //
135 ////////////////////////////////////////////////////////////////////////
136 {
137 }
138
139 ////////////////////////////////////////////////////////////////////////
140 //
141 // Description:
142 // Prints element for debugging.
143 //
144 // Use: public
145 //
146 ////////////////////////////////////////////////////////////////////////
147
148 #ifdef DEBUG
149 void
150 SoElement::print(FILE *fp) const
151 {
152 fprintf(fp, "Element: type %s, depth %d\n",
153 typeId.getName().getString(), depth);
154 }
155 #else /* DEBUG */
156 void
157 SoElement::print(FILE *) const
158 {
159 }
160 #endif /* DEBUG */
161
162 ////////////////////////////////////////////////////////////////////////
163 //
164 // Description:
165 // Returns the id for the element with the given stack index.
166 //
167 // Use: internal static, debug only!
168
169 SoType
170 SoElement::getIdFromStackIndex(int stackIndex)
171 //
172 ////////////////////////////////////////////////////////////////////////
173 {
174 #ifdef DEBUG
175 return (*stackToType)[stackIndex];
176 #else
177 return SoType::badType();
178 #endif
179 }
180
181 ////////////////////////////////////////////////////////////////////////
182 //
183 // Description:
184 // Creates and returns a new stack index for an element class to
185 // use within SoState instances. It is passed the type id of the
186 // element class so we can correlate stack indices to type id's for
187 // debugging purposes.
188 //
189 // Use: internal protected
190
191 int
192 SoElement::createStackIndex(SoType id)
193 //
194 ////////////////////////////////////////////////////////////////////////
195 {
196 int stackIndex = nextStackIndex++;
197
198 #ifdef DEBUG
199 // Store id in list so we can get it from stack index later
200 stackToType->set(stackIndex, id);
201 #endif
202
203 return stackIndex;
204 }
205
206 #undef FREE_LIST_INCREMENT
207
208 ////////////////////////////////////////////////////////////////////////
209 //
210 // Description:
211 // "Captures" this element for caching purposes. The element is
212 // added to all currently open caches, using the SoCacheElement.
213 //
214 // Use: virtual, protected
215
216 void
217 SoElement::captureThis(SoState *state) const
218 //
219 ////////////////////////////////////////////////////////////////////////
220 {
221 SoCacheElement::addElement(state, this);
222 }
223