Debian Codegraph @

src/h/ST_Agnode_s.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program:
18 *
19 *************************************************************************
20 * Copyright (c) 2011 AT&T Intellectual Property
21 * All rights reserved. This program and the accompanying materials
22 * are made available under the terms of the Eclipse Public License v1.0
23 * which accompanies this distribution, and is available at
24 * http://www.eclipse.org/legal/epl-v10.html
25 *
26 * Contributors: See CVS logs. Details at http://www.graphviz.org/
27 *************************************************************************
28 *
29 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
30 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
31 *
32 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
33 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
34 *
35 * You may obtain a copy of the License at
36 *
37 * http://www.eclipse.org/legal/epl-v10.html
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 */
46 package h;
47
48 import java.util.ArrayList;
49 import java.util.List;
50
51 import smetana.core.UnsupportedArrayOfPtr;
52 import smetana.core.UnsupportedArrayOfStruct2;
53 import smetana.core.UnsupportedStructAndPtr;
54 import smetana.core.__array_of_ptr__;
55 import smetana.core.__ptr__;
56 import smetana.core.__struct__;
57 import smetana.core.size_t;
58 import smetana.core.amiga.StarStruct;
59
60 public class ST_Agnode_s extends UnsupportedStructAndPtr {
61
62 public final ST_Agobj_s base = new ST_Agobj_s(this);
63 public ST_Agraph_s root;
64 public final ST_Agsubnode_s mainsub = new ST_Agsubnode_s(this);
65
66 private final StarStruct parent;
67
68 public static class ArrayOfStar extends UnsupportedArrayOfPtr implements __ptr__, __array_of_ptr__ {
69
70 private final List<ST_Agnode_s> data;
71 private final int pos;
72
73 public ArrayOfStar(int size) {
74 this.data = new ArrayList<ST_Agnode_s>();
75 this.pos = 0;
76 for (int i = 0; i < size; i++) {
77 data.add(null);
78 }
79 }
80
81 public void swap(int i, int j) {
82 ST_Agnode_s e1 = data.get(i);
83 ST_Agnode_s e2 = data.get(j);
84 data.set(i, e2);
85 data.set(j, e1);
86 }
87
88 public ArrayOfStar(List<ST_Agnode_s> data, int pos) {
89 this.data = data;
90 this.pos = pos;
91 }
92
93 public ArrayOfStar reallocJ(int newsize) {
94 while (data.size() < newsize) {
95 data.add(null);
96 }
97 return this;
98 }
99
100 @Override
101 public ArrayOfStar plus(int delta) {
102 return new ArrayOfStar(data, pos + delta);
103 }
104
105 @Override
106 public ArrayOfStar asPtr() {
107 return this;
108 }
109
110 @Override
111 public void setPtr(__ptr__ value) {
112 this.data.set(pos, (ST_Agnode_s) value);
113 }
114
115 public ST_Agnode_s get(int i) {
116 return plus(i).getPtr();
117 }
118
119 @Override
120 public ST_Agnode_s getPtr() {
121 return this.data.get(pos);
122 }
123
124 @Override
125 public int comparePointer(__ptr__ other) {
126 final ArrayOfStar this2 = (ArrayOfStar) other;
127 if (this.data != this2.data) {
128 throw new IllegalArgumentException();
129 }
130 return this.pos - this2.pos;
131 }
132
133 public boolean isSameThan2(ArrayOfStar other) {
134 if (this.data != other.data) {
135 throw new IllegalArgumentException();
136 }
137 return this.pos == other.pos;
138 }
139 }
140
141 public static class Array extends UnsupportedArrayOfStruct2 implements __ptr__, __array_of_ptr__ {
142
143 private final List<ST_Agnode_s> data;
144 private final int pos;
145
146 @Override
147 public void setStruct(__struct__ value) {
148 get(0).___(value);
149 }
150
151 @Override
152 public Array asPtr() {
153 return this;
154 }
155
156 public Array(int size) {
157 this.data = new ArrayList<ST_Agnode_s>();
158 this.pos = 0;
159 for (int i = 0; i < size; i++) {
160 data.add(new ST_Agnode_s());
161 }
162 }
163
164 public Array reallocJ(int newsize) {
165 while (data.size() < newsize) {
166 data.add(new ST_Agnode_s());
167 }
168 return this;
169 }
170
171 public Array plus(int delta) {
172 return plusJ(delta);
173 }
174
175 @Override
176 public void setPtr(__ptr__ value) {
177 this.data.set(pos, (ST_Agnode_s) value);
178 }
179
180 @Override
181 public ST_Agnode_s getPtr() {
182 return this.data.get(pos);
183 }
184
185 private Array(List<ST_Agnode_s> data, int pos) {
186 this.data = data;
187 this.pos = pos;
188 }
189
190 public ST_Agnode_s get(int i) {
191 return this.data.get(pos + i);
192 }
193
194 public Array plusJ(int i) {
195 return new Array(data, pos + i);
196 }
197
198 public int minus(Array other) {
199 if (this.data != other.data) {
200 throw new IllegalArgumentException();
201 }
202 return this.pos - other.pos;
203 }
204
205 public Array move(int delta) {
206 throw new UnsupportedOperationException(getClass().toString());
207 }
208
209 public void realloc(size_t nb) {
210 throw new UnsupportedOperationException(getClass().toString());
211 }
212
213 public int comparePointerInternal(__array_of_ptr__ other) {
214 throw new UnsupportedOperationException(getClass().toString());
215 }
216
217
218 }
219
220 public ST_Agnode_s() {
221 this(null);
222 }
223
224 public ST_Agnode_s(StarStruct parent) {
225 this.parent = parent;
226 }
227
228 public StarStruct getParent() {
229 return parent;
230 }
231
232 @Override
233 public __ptr__ castTo(Class dest) {
234 if (dest == ST_Agnode_s.class) {
235 return this;
236 }
237 if (dest == ST_Agobj_s.class) {
238 return base;
239 }
240 return super.castTo(dest);
241 }
242
243 public ST_Agobj_s castTo_ST_Agobj_s() {
244 return base;
245 }
246
247 @Override
248 public boolean isSameThan(StarStruct other) {
249 ST_Agnode_s other2 = (ST_Agnode_s) other;
250 return this == other2;
251 }
252
253 @Override
254 public __ptr__ setPtr(String fieldName, __ptr__ newData) {
255 if (fieldName.equals("root")) {
256 this.root = (ST_Agraph_s) newData;
257 return root;
258 }
259 return super.setPtr(fieldName, newData);
260 }
261
262 @Override
263 public ST_Agnode_s getStruct() {
264 return this;
265 }
266
267 // public static List<String> DEFINITION = Arrays.asList(
268 // "struct Agnode_s",
269 // "{",
270 // "Agobj_t base",
271 // "Agraph_t *root",
272 // "Agsubnode_t mainsub",
273 // "}");
274 }
275
276 // struct Agnode_s {
277 // Agobj_t base;
278 // Agraph_t *root;
279 // Agsubnode_t mainsub; /* embedded for main graph */
280 // };