forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattrDescriptor.h
More file actions
206 lines (177 loc) · 6.26 KB
/
attrDescriptor.h
File metadata and controls
206 lines (177 loc) · 6.26 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#ifndef ATTRDESCRIPTOR_H
#define ATTRDESCRIPTOR_H
#include "typeDescriptor.h"
#include "cldai/sdaiEnum.h"
#include "sc_export.h"
enum AttrType_Enum {
AttrType_Explicit = 0,
AttrType_Inverse,
AttrType_Deriving,
AttrType_Redefining
};
class EntityDescriptor;
/** AttrDescriptor
* An instance of this class will be generated for each attribute for
* an Entity. They will be pointed to by the EntityTypeDescriptors.
*/
class SC_CORE_EXPORT AttrDescriptor {
protected:
const char * _name; // the attributes name
// this defines the domain of the attribute
const TypeDescriptor * _domainType;
SDAI_LOGICAL _optional;
SDAI_LOGICAL _unique;
AttrType_Enum _attrType; // former attribute _derived
const EntityDescriptor & _owner; // the owning entityDescriptor
public:
AttrDescriptor(
const char * name, // i.e. char *
const TypeDescriptor * domainType,
Logical optional, // i.e. F U or T
Logical unique, // i.e. F U or T
AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse,
// AttrType_Deriving,AttrType_Redefining
const EntityDescriptor & owner
);
virtual ~AttrDescriptor();
const char * GenerateExpress( std::string & buf ) const;
// the attribute Express def
virtual const char * AttrExprDefStr( std::string & s ) const;
// left side of attr def
const char * Name() const {
return _name;
}
void Name( const char * n ) {
_name = n;
}
/** BaseType() is the underlying type of this attribute.
* NonRefType() is the first non REFERENCE_TYPE type
* e.g. Given attributes of each of the following types
* TYPE count = INTEGER;
* TYPE ref_count = count;
* TYPE count_set = SET OF ref_count;
* BaseType() will return INTEGER_TYPE for an attr of each type.
* BaseTypeDescriptor() returns the TypeDescriptor for Integer
* NonRefType() will return INTEGER_TYPE for the first two. For an
* attribute of type count_set NonRefType() would return
* AGGREGATE_TYPE
* NonRefTypeDescriptor() returns the TypeDescriptor for Integer
* for the first two and a TypeDescriptor for an
* aggregate for the last.
*
* \sa NonRefType()
* \sa NonRefTypeDescriptor()
*/
///@{
PrimitiveType BaseType() const;
const TypeDescriptor * BaseTypeDescriptor() const;
///@}
/**
* the first PrimitiveType that is not REFERENCE_TYPE (the first
* TypeDescriptor *_referentType that does not have REFERENCE_TYPE
* for it's fundamentalType variable). This would return the same
* as BaseType() for fundamental types. An aggregate type
* would return AGGREGATE_TYPE then you could find out the type of
* an element by calling AggrElemType(). Select types
* would work the same?
*
* \sa BaseType()
*/
///@{
PrimitiveType NonRefType() const;
const TypeDescriptor * NonRefTypeDescriptor() const;
///@}
int IsAggrType() const;
PrimitiveType AggrElemType() const;
const TypeDescriptor * AggrElemTypeDescriptor() const;
/// The type of the attributes TypeDescriptor
PrimitiveType Type() const;
/// right side of attr def
const std::string TypeName() const;
/// an expanded right side of attr def
const char * ExpandedTypeName( std::string & s ) const;
int RefersToType() const {
return !( _domainType == 0 );
}
const TypeDescriptor * ReferentType() const {
return _domainType;
}
const TypeDescriptor * DomainType() const {
return _domainType;
}
void DomainType( const TypeDescriptor * td ) {
_domainType = td;
}
void ReferentType( const TypeDescriptor * td ) {
_domainType = td;
}
const SDAI_LOGICAL & Optional() const {
return _optional;
}
void Optional( SDAI_LOGICAL & opt ) {
_optional.put( opt.asInt() );
}
void Optional( Logical opt ) {
_optional.put( opt );
}
void Optional( const char * opt ) {
_optional.put( opt );
}
const SDAI_LOGICAL & Unique() const {
return _unique;
}
void Unique( SDAI_LOGICAL uniq ) {
_unique.put( uniq.asInt() );
}
void Unique( Logical uniq ) {
_unique.put( uniq );
}
void Unique( const char * uniq ) {
_unique.put( uniq );
}
void AttrType( enum AttrType_Enum ate ) {
_attrType = ate;
}
enum AttrType_Enum AttrType() const {
return _attrType;
}
Logical Explicit() const;
Logical Inverse() const;
Logical Redefining() const;
Logical Deriving() const;
//outdated functions, use AttrType func above, new support of redefined
Logical Derived() const {
return Deriving();
}
void Derived( Logical x ); // outdated DAS
void Derived( SDAI_LOGICAL x ); // outdated DAS
void Derived( const char * x ); // outdated DAS
const SDAI_LOGICAL & Optionality() const {
return _optional;
}
void Optionality( SDAI_LOGICAL & opt ) {
_optional.put( opt.asInt() );
}
void Optionality( Logical opt ) {
_optional.put( opt );
}
void Optionality( const char * opt ) {
_optional.put( opt );
}
const SDAI_LOGICAL & Uniqueness() const {
return _unique;
}
void Uniqueness( SDAI_LOGICAL uniq ) {
_unique.put( uniq.asInt() );
}
void Uniqueness( Logical uniq ) {
_unique.put( uniq );
}
void Uniqueness( const char * uniq ) {
_unique.put( uniq );
}
const EntityDescriptor & Owner() const {
return _owner;
}
};
#endif //ATTRDESCRIPTOR_H