| 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_FIELD_ |
| 22 |
#define _QV_FIELD_ |
| 23 |
|
| 24 |
#include <stdlib.h> |
| 25 |
#include <QvString.h> |
| 26 |
|
| 27 |
class QvInput; |
| 28 |
class QvNode; |
| 29 |
|
| 30 |
class QvField { |
| 31 |
public: |
| 32 |
virtual ~QvField(); |
| 33 |
|
| 34 |
QvBool isDefault() const { return flags.hasDefault; } |
| 35 |
|
| 36 |
QvNode * getContainer() const { return container; } |
| 37 |
|
| 38 |
void setDefault(QvBool def) { flags.hasDefault = def; } |
| 39 |
void setContainer(QvNode *cont); |
| 40 |
QvBool read(QvInput *in, const QvName &name); |
| 41 |
|
| 42 |
QvField() { flags.hasDefault = TRUE; } |
| 43 |
|
| 44 |
public: |
| 45 |
|
| 46 |
private: |
| 47 |
struct { |
| 48 |
unsigned int hasDefault : 1; // Field is set to default value |
| 49 |
} flags; |
| 50 |
|
| 51 |
QvNode *container; |
| 52 |
|
| 53 |
static QvField * createInstanceFromName(const QvName &className); |
| 54 |
virtual QvBool readValue(QvInput *in) = 0; |
| 55 |
|
| 56 |
friend class QvFieldData; |
| 57 |
}; |
| 58 |
|
| 59 |
class QvSField : public QvField { |
| 60 |
public: |
| 61 |
virtual ~QvSField(); |
| 62 |
|
| 63 |
protected: |
| 64 |
QvSField(); |
| 65 |
|
| 66 |
private: |
| 67 |
virtual QvBool readValue(QvInput *in) = 0; |
| 68 |
}; |
| 69 |
|
| 70 |
class QvMField : public QvField { |
| 71 |
|
| 72 |
public: |
| 73 |
int num; // Number of values |
| 74 |
int maxNum; // Number of values allocated |
| 75 |
|
| 76 |
// Destructor |
| 77 |
virtual ~QvMField(); |
| 78 |
|
| 79 |
protected: |
| 80 |
QvMField(); |
| 81 |
virtual void makeRoom(int newNum); |
| 82 |
|
| 83 |
private: |
| 84 |
virtual void allocValues(int num) = 0; |
| 85 |
virtual QvBool readValue(QvInput *in); |
| 86 |
virtual QvBool read1Value(QvInput *in, int index) = 0; |
| 87 |
}; |
| 88 |
|
| 89 |
#endif /* _QV_FIELD_ */ |