Menu

[2179ca]: / attribute.h  Maximize  Restore  History

Download this file

94 lines (78 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H
#include <QStringList>
#include <QVariant>
#include "xmlobj.h"
class AttributeTable; //FIXME-3 remove from CVS
class AttributeDef; //FIXME-3 remove from CVS
enum AttributeType {
Undefined, //!< Undefined type
IntList, //!< Free integer
FreeInt, //!< Free integer
StringList, //!< List of strings, one can be attribute value
FreeString, //!< Any string can be attribute value, not unique
UniqueString//!< UniqueString, e.g. for IDs
};
/*! \brief A key and a value
The data itself is stored in Attribute Definitions (AttributeDef).
A list of these tables AttributeTable is maintained for every MapEditor.
*/
class Attribute:public XMLObj {
public:
Attribute();
void setKey (const QString &k, const AttributeType &t);
QString getKey ();
void setValue (const QString &v);
QVariant getValue ();
void setType (const AttributeType &t);
AttributeType getType ();
QString getTypeString ();
void setTable (AttributeTable *at);
AttributeTable* getTable();
QString getDataXML();
protected:
AttributeTable *table;
AttributeDef *definition;
QString freeString; //!< String value for type FreeString
};
/*! \brief
Attribute definition, defines possible values and type of attribute.
*/
class AttributeDef {
public:
AttributeDef();
~AttributeDef();
void setType (const AttributeType &t);
AttributeType getType();
QString getTypeString ();
void setKey (const QString &k);
QString getKey ();
void setValue (const QString &v);
void setValue (const QVariant &v);
QVariant getValue ();
private:
QString key;
AttributeType type;
QVariant value; //!< value (except FreeString, FreeInt ...
};
/*! \brief A table containing a list of keys and each of these keys has
a list of default values. The keys and the values for each key are
unique.
*/
class AttributeTable:public XMLObj{
public:
AttributeTable();
~AttributeTable();
void clear();
AttributeDef* addKey (const QString &k, const AttributeType &t); //!< Adds a key to the table
void removeKey (const QString &k); //!< Removes key and its default values
AttributeDef* getDef(const QString &k); //!< Get defintion of attribute
int countKeys(); //!< Return number of keys
QStringList getKeys ();
QStringList getTypes();
QString getDataXML();
protected:
QList <AttributeDef*> attdefs;
QStringList typeList;
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.