Debian Codegraph @

src/bin/geomutil/vrml2oogl/lib/QvNode.h

raw
1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21 #ifndef _QV_NODE_
22 #define _QV_NODE_
23
24 #include <QvString.h>
25
26 class QvChildList;
27 class QvDict;
28 class QvFieldData;
29 class QvInput;
30 class QvNodeList;
31 class QvState;
32
33 class QvNode {
34
35 public:
36 enum Stage {
37 FIRST_INSTANCE, // First real instance being constructed
38 PROTO_INSTANCE, // Prototype instance being constructed
39 OTHER_INSTANCE // Subsequent instance being constructed
40 };
41
42 QvFieldData *fieldData;
43 QvChildList *children;
44 QvBool isBuiltIn;
45
46 QvName *objName;
47 QvNode();
48 virtual ~QvNode();
49
50 // Reference counting:
51 long refCount;
52 void ref() const; // Adds reference
53 void unref() const; // Removes reference, deletes if now 0
54 void unrefNoDelete() const; // Removes reference, never deletes
55
56 const QvName & getName() const;
57 void setName(const QvName &name);
58
59 static void init();
60 static QvBool read(QvInput *in, QvNode *&node);
61
62 virtual QvFieldData *getFieldData() = 0;
63
64 virtual void traverse(QvState *state) = 0;
65 virtual void ToWebOOGL(QvState *state) = 0;
66
67 protected:
68 virtual QvBool readInstance(QvInput *in);
69
70 private:
71 static QvDict *nameDict;
72
73 static void addName(QvNode *, const char *);
74 static void removeName(QvNode *, const char *);
75 static QvNode * readReference(QvInput *in);
76 static QvBool readNode(QvInput *in, QvName &className,QvNode *&node);
77 static QvBool readNodeInstance(QvInput *in, const QvName &className,
78 const QvName &refName, QvNode *&node);
79 static QvNode * createInstance(QvInput *in, const QvName &className);
80 static QvNode * createInstanceFromName(const QvName &className);
81 static void flushInput(QvInput *in);
82 };
83
84 #endif /* _QV_NODE_ */