/* Copyright (C) 1992-1998 The Geometry Center * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips * * This file is part of Geomview. * * Geomview is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2, or (at your option) * any later version. * * Geomview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with Geomview; see the file COPYING. If not, write * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, * USA, or visit http://www.gnu.org. */ #ifndef _QV_NODE_ #define _QV_NODE_ #include class QvChildList; class QvDict; class QvFieldData; class QvInput; class QvNodeList; class QvState; class QvNode { public: enum Stage { FIRST_INSTANCE, // First real instance being constructed PROTO_INSTANCE, // Prototype instance being constructed OTHER_INSTANCE // Subsequent instance being constructed }; QvFieldData *fieldData; QvChildList *children; QvBool isBuiltIn; QvName *objName; QvNode(); virtual ~QvNode(); // Reference counting: long refCount; void ref() const; // Adds reference void unref() const; // Removes reference, deletes if now 0 void unrefNoDelete() const; // Removes reference, never deletes const QvName & getName() const; void setName(const QvName &name); static void init(); static QvBool read(QvInput *in, QvNode *&node); virtual QvFieldData *getFieldData() = 0; virtual void traverse(QvState *state) = 0; virtual void ToWebOOGL(QvState *state) = 0; protected: virtual QvBool readInstance(QvInput *in); private: static QvDict *nameDict; static void addName(QvNode *, const char *); static void removeName(QvNode *, const char *); static QvNode * readReference(QvInput *in); static QvBool readNode(QvInput *in, QvName &className,QvNode *&node); static QvBool readNodeInstance(QvInput *in, const QvName &className, const QvName &refName, QvNode *&node); static QvNode * createInstance(QvInput *in, const QvName &className); static QvNode * createInstanceFromName(const QvName &className); static void flushInput(QvInput *in); }; #endif /* _QV_NODE_ */